Openreport "where" condition....

G

Guest

HI,

I'm trying filter a report based on a combobox selection. Previously done
fine with a macro, I'm just trying to de-macro my database. But, I cannot get
the "where" condition to do anything! All I get is an empty report.

The sub is attatched to a button on the same form as the combo:
-

Private Sub Command47_Click()

DoCmd.OpenReport "rptTLNew", acViewPreview, , Project_Name =
Forms!frmTLReportCallup!compj
End Sub
-

compj = the combo box with the filter criteria.
frmTLReportCallup = the form with the controls
Project_Name = the field in the query underlying the report


Vba help tells me that this is the proper syntax for a where condition:
[fieldname] = Forms![formname]![controlname on form]. This does not seem to
work. I have tried putting "" around everything, nothing and each individual
section of the condition, with no joy.

I am guessing that the problem is to do with an incorrect !, ", [ etc, but I
cannot see where or more importantly why.

Thanks for looking
 
A

Al Camp

Zilla,
If CompJ contains a legitimate value for Project_Name,
and
both fields are Text,
and
the frmTLReportCallup is open at the time the report is run, then...

DoCmd.OpenReport "rptTLNew", acViewPreview, , "Project_Name =
Forms!frmTLReportCallup!compj" '(all on one line)
End Sub

should work.

Note: If you just entered the CompJ value on the form, do a Refresh before running the
report
 
S

Stefan Hoffmann

hi,
Private Sub Command47_Click()

DoCmd.OpenReport "rptTLNew", acViewPreview, , Project_Name =
Forms!frmTLReportCallup!compj
You must enclose your condition in quotes:
...., "Project_Name=Forms!..."


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top