G
Guest
I am trying to pass var1 to a paramater query to automate the export of multiple files.
I know var1 is picking up the correct values and that when I run the query and type the parameter manually it works ok.
Can anyone see issues with the code?
Dave
Sub DataExport_loop()
Dim strfile, expdir As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tbl_Company", dbOpenTable)
expdir = CurrentProject.Path & "\Export\"
strfile = (Dir(expdir & "*.txt"))
With rst
Do While Not .EOF
MsgBox (rst!ASXCode.Value)
var1 = rst!ASXCode.Value
DoCmd.SetWarnings False
DoCmd.TransferText acExportDelim, "ImportSpec", "qry_ASXData_Export", expdir & strfile, False
MsgBox ("Step 1: Data Exported")
rst.MoveNext
Loop
End With
End Sub
I know var1 is picking up the correct values and that when I run the query and type the parameter manually it works ok.
Can anyone see issues with the code?
Dave
Sub DataExport_loop()
Dim strfile, expdir As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tbl_Company", dbOpenTable)
expdir = CurrentProject.Path & "\Export\"
strfile = (Dir(expdir & "*.txt"))
With rst
Do While Not .EOF
MsgBox (rst!ASXCode.Value)
var1 = rst!ASXCode.Value
DoCmd.SetWarnings False
DoCmd.TransferText acExportDelim, "ImportSpec", "qry_ASXData_Export", expdir & strfile, False
MsgBox ("Step 1: Data Exported")
rst.MoveNext
Loop
End With
End Sub