simple report question

B

bmdavis

Hi,
I have created a button that calls up a REPORT in print preview. I
want to make sure this button only calls up the appropriate fields in
REPORT based on what the user enters after a USER PROMPT (i.e. it
should ask for "Last Name" before going to print preview). What's the
easiest way to do this?

Thanks.
 
D

Duane Hookom

What do you mean by "calls up the appropriate fields"? Is this for filtering
or are you trying to hide controls on your report?
 
B

bmdavis

Thanks for the quick reply... Sorry about that, my fault with
language. I want to call up a report with a button. However, after I
press this button, I went the form to be filtered by the text I enter
after a user prompt. So the actual report is always the same, I just
want it to display a few pages instead of ALL the pages of the report.
Does that help?
 
D

Duane Hookom

Apparently you want to be able to enter text into a text box on your form
and use it to filter the records returned in your report. I would allow the
command button wizard to create the DoCmd.OpenReport procedure for you. Then
add code like:

Dim strWhere as String
strWhere = "1=1 "
If not IsNull(Me.txtYourTextBox) Then
strWhere = strWhere & " and [YourTextField] = """ & _
Me.txtYourTextBox & """"
End If
DoCmd.OpenReport "rptYourReport", acPreview, , strWhere
 
Top