fryguy5049
Technical User
I am receiving the error "Item not found in this collection"
The parameters I am attempting to pass to this code are in 2 text boxes of the form(start date & end date). The form is open when I try to run the module & I am using Access 2000.
The code fails on this line:
qdf.Parameters(1) = Forms!fdr_batch!startdate
When I go into debug mode and hover the cursor over this line it shows the correct parameter from the form (start date). Any ideas why it doesn't work?
Here is the rest of the code:
The parameters I am attempting to pass to this code are in 2 text boxes of the form(start date & end date). The form is open when I try to run the module & I am using Access 2000.
The code fails on this line:
qdf.Parameters(1) = Forms!fdr_batch!startdate
When I go into debug mode and hover the cursor over this line it shows the correct parameter from the form (start date). Any ideas why it doesn't work?
Here is the rest of the code:
Code:
Sub ExportTextFile()
Dim db As Database, rst As DAO.Recordset
Dim qdf As QueryDef
Dim Directory As String
Dim MyString As String, strSQL As String
Dim prm As DAO.Parameter
Dim rec_cnt As Integer
Set db = CurrentDb
Directory = (Mid(db.Name, 1, Len(db.Name) - Len(Dir(db.Name))))
Open Directory & "\TestOutput.txt" For Output As #1
Set rst = db.OpenRecordset("FDR batch xport")
Set qdf = db.QueryDefs("FDR batch xport")
qdf.Parameters(1) = Forms!fdr_batch!startdate
qdf.Parameters(2) = Forms!fdr_batch!enddate
Print #1, "HDAJFEBB" & Format(Date, "mmddyy") & Format(Time, "hhmmss")
Do While Not rst.EOF
MyString = rst!CHaccount & rst!merc_num & rst!filler & rst!fee_text
Print #1, MyString
rst.MoveNext
Loop
Print #1, "TLAJFEBB" & Format(rst.RecordCount + 2, "0000000000") & Format(rst.RecordCount * 15, "000000000000000") & "00"
ExportTextFile_Exit:
' Close text file.
Close #1
rst.Close
Set db = Nothing
Exit Sub
End Sub