using Form data in query

  • Thread starter Thread starter shank
  • Start date Start date
S

shank

I'm trying to run a query with the below statement as criteria.

I'm trying to get by with designing one report and having it open per the
form being used.

Problem: It insists on evaluating the form field that is not used. How do I
get around that?

I would like the query to run regardless of which form is used.

IIf(IsNull([Forms]![frmAllPO]![PONo]),[Forms]![frmTempReport]![PONo],[Forms]![frmAllPO]![PONo])

thanks
 
One way to do this is to write a custom VBA function that will check to
see which form is open and then grab the information from the form and
return the desired value.

Another way - if you are using this query as the source for a report -
is to pass a where string when your code opens the report.

Something like the following.

Dim strWhere as String

strWhere = "[Name of the field]=""" & [Forms]![frmTempReport]![PONo] & """"
Docmd.OpenReport "ReportName",,,strWhere
 
Back
Top