Printing Based on a value in a form

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

Guest

I have a text box on a form named MainMenu unbound to any table or querry. I
have a report called RWidgets which is based on a table called TableWidget.

On the MainMenu I have a text box called WidgetNames.

Question. With a command button on the MainMenu... OnClick I want to Print
the report to match the records with the value in the textbox called
WidgetNames.

I know I could base the Report on a Perimeter Query but I dont want to do it
that way. Thanks.
 
dim strWhere as string

strWhere = "WidgetFieldName = '" & me.WidgetNames & "'"

docmd.openReport "RWidgets",,,strWhere

If you want the reprot to preview, then use

docmd.openReport "RWidgets",acViewPreview,,strWhere

And, note the quotes used

strWhere = "WidgetFieldName = ' " & me.WidgetNames & " ' "

The above has extra spaces around the quotes for ease of reading in this
post, but you want to use the syntax as the first example shows...

Note that if the widget name is actually a number type field, then you can
remove the single quotes....
 
Thanks, But I sure feel stupid. I have done this before with a list box
based on a single record Thanks for curing a serious case of going from dumb
to completely stupid.
 
Back
Top