docmd.transfertext 使用查询名称
docmd.transfertext using queryname
我正在尝试仅将某些数据从 table 导出到 CSV 文件。
如果我导出整个 table,它会完美导出,但如果我尝试仅导出选定的数据,则没有任何反应。我正在为要导出的数据使用查询名称。我没有收到任何错误消息,所以我不知道出了什么问题。
非常感谢任何帮助。
嗯,到目前为止我的代码如下..
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String, strQ As String
Dim Path As String
Dim CustomerId As String
Path = Me.TxFilePath.Value
CustomerId = Me.OpenArgs
Set dbs = CurrentDb
strSQL = "Select table.*" & _
"From table" & _
"Where table.[name] = 'CustomerId';"
Set qdf = dbs.CreateQueryDef("strQ", strSQL)
MsgBox CustomerId, vbOKOnly + vbInformation, "Export"
Set qdf = Nothing
DoCmd.TransferText acExportDelim, , strQ, Path, True
dbs.QueryDefs.Delete strQ
Set qdf = Nothing
dbs.Close
Set dbs = Nothing
End Sub
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String, strQ As String
Dim Path As String
Dim CustomerId As Integer
Path = Me.TxFilePath.Value
CustomerId = CInt(Me.OpenArgs)
strSQL = "Select *" _
& " From Table" _
& " Where Name = " & CustomerId & ""
Set dbs = CurrentDb
Set dbs = CurrentDb()
Set qdf = dbs.CreateQueryDef("strQ", strSQL)
Set qdf = Nothing
dbs.Close
Set dbs = Nothing
DoCmd.TransferText acExportDelim, , "strQ", Path, True
DoCmd.DeleteObject acQuery, "strQ"
我正在尝试仅将某些数据从 table 导出到 CSV 文件。
如果我导出整个 table,它会完美导出,但如果我尝试仅导出选定的数据,则没有任何反应。我正在为要导出的数据使用查询名称。我没有收到任何错误消息,所以我不知道出了什么问题。
非常感谢任何帮助。
嗯,到目前为止我的代码如下..
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String, strQ As String
Dim Path As String
Dim CustomerId As String
Path = Me.TxFilePath.Value
CustomerId = Me.OpenArgs
Set dbs = CurrentDb
strSQL = "Select table.*" & _
"From table" & _
"Where table.[name] = 'CustomerId';"
Set qdf = dbs.CreateQueryDef("strQ", strSQL)
MsgBox CustomerId, vbOKOnly + vbInformation, "Export"
Set qdf = Nothing
DoCmd.TransferText acExportDelim, , strQ, Path, True
dbs.QueryDefs.Delete strQ
Set qdf = Nothing
dbs.Close
Set dbs = Nothing
End Sub
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String, strQ As String
Dim Path As String
Dim CustomerId As Integer
Path = Me.TxFilePath.Value
CustomerId = CInt(Me.OpenArgs)
strSQL = "Select *" _
& " From Table" _
& " Where Name = " & CustomerId & ""
Set dbs = CurrentDb
Set dbs = CurrentDb()
Set qdf = dbs.CreateQueryDef("strQ", strSQL)
Set qdf = Nothing
dbs.Close
Set dbs = Nothing
DoCmd.TransferText acExportDelim, , "strQ", Path, True
DoCmd.DeleteObject acQuery, "strQ"