access open report where condition

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In VBA I'm trying to write an docmd openreport routine where the
"wherecondition" is entered by the user. Has anyone every written something
like this and what is the proper syntax? I have successfully used this
procedure where the condition is hard coded by never a variable.
 
It is theoretically possible to let a user enter the WhereCondition string
into (say) a text box named txtWhere on a form named Form1, and then:
DoCmd.OpenReport, acViewPreview, , Forms!Form1!txtWhere

However, that's not a very good interface unless your users understand SQL
WHERE clauses. A better interface is to build the string from the controls
where they enter the *values* associated with particular fields. For a
couple of examples of doing that, see:
Limiting a Report to a Date Range
at:
http://allenbrowne.com/casu-08.html
and:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html
 
Back
Top