Results 1 to 2 of 2

Thread: [RESOLVED] export form records with filters to a text file

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    Resolved [RESOLVED] export form records with filters to a text file

    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

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    Re: export form records with filters to a text file

    anyone ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width