Consulting

Results 1 to 2 of 2

Thread: SQL statement as Report record source

  1. #1

    SQL statement as Report record source

    I do very little VBA programming now, but did a lot long ago.
    I have an Access form used to display the results of a generic lookup of a database. I build a SQL statement based upon fields in the form header and make it the record source of the form, with the result found records displayed in the body of the form.

    I need to print a report using the same lookup criteria. How do I make the created SQL statement the record source of the report?

  2. #2
    VBAX Expert
    Joined
    Oct 2012
    Posts
    726
    Location
    Filters for forms, reports, dlookups, etc are just SQL WHERE criteria.

    me.recordsource = "select * from table1 WHERE fld1 like '*foo*'"

    Me.Filter = "fld2 like '*bar*'"
    FilterOn = True
    ...
    DoCmd.OpenReport "report1", acViewPreview, , Me.Filter

Posting Permissions

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