Hello-
I figured it out and thought I would post the code to avoid future headaches for someone else.
- First I created 2 global variables to house my loc1 and loc2 fields
- Then I created a select all query for the data I needed to export...only I needed to use the getLoc1() function as a parameter for the Loc1 criteria and the getLoc2() function as a parameter for the loc2 criteria
- Lastly a do loop on the recordset and I'm also able to control where the file outputs to and the name.
The code:
Global gStrLoc1 As String
Global gStrLoc2 As String
Public Function GetLoc1() As String
GetLoc1 = gStrLoc1
End Function
Public Function GetLoc2() As String
GetLoc2 = gStrLoc2
End Function
Public Function ExpHourlyCheck()
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "Select * FROM ***insert your table name here****"
Do Until .EOF
gStrLoc1 = !CNL1LC (***my location1 variable***)
gStrLoc2 = !CNL2LC (***my location2 variable***)
DoCmd.TransferText acExportDelim, "PayrollExport Specs", "qryHourlyCheckExport", "\\MFFS05\MIS\Financials\Payroll " & !CNL1LC & !CNL2LC & Format(Now(), "mmddyyhhnnss") & " .csv", False
.MoveNext
Loop
.Close
End With
Set rst = Nothing
End Function
|