Printing Based on a value in a form

B

BrianPaul

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.
 
A

Albert D. Kallal

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....
 
B

BrianPaul

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.
 

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