Hey everyone,

I'm trying to export an access form records to a text file with a certain structure.

Thing is I can't get it to consider the current form filter. When I use my code it exports all the form records no matter what the filter is.

here's my code:

----------------------------------------------

Private Sub create_txt_file_Click()
Dim rs As DAO.Recordset
Dim StrQryName As String
Dim OutFile As String


StrQryName = "My_Forms_Query"
OutFile = "g:\My_Form_Records.txt"

Open OutFile For Output As #1

Set rs = CurrentDb.OpenRecordset(StrQryName)
If Me.FilterOn = True Then rs.filter = Me.filter
rs.OpenRecordset

rs.MoveFirst
Do Until rs.EOF
Print #1, rs("field_1") & " " & rs("field_2")
rs.MoveNext
Loop
rs.Close
Close #1

End Sub