User entering search criteria

L

LouisPat

Hi!

I want to create a form with a text box that asks the user a number. When
the user enters the number and click on a preview button, it will open a
report and filter data (static pressure of hydrants < 75, for example) from a
table. I don't want the the text box to appear in pop up (input box). I want
it to appear directly on the form if it is possible, as I have other criteria
to look for in my form

This is the code I designed but it obviously don't work. Can someone help
me? I work in Access 2000
Thanks
Louis Pat

CODE:

Sub PrintReports(Printmode As Integer)
Dim TheNumber As Integer
On Error GoTo Err_Preview_Click
Me!Number.SetFocus
' Number is the name of the textbox
TheNumber = Me!Number.Text

DoCmd.OpenReport "hydrant report", Printmode, , "[Static
Pressure] < TheNumber "
Exit_Preview_Click:
Exit Sub
Err_Preview_Click:
Resume Exit_Preview_Click
End Sub
 
A

Allen Browne

Concatente the number onto the WhereCondition string:

DoCmd.OpenReport "hydrant report", Printmode, , "[Static Pressure] < " &
Me.Number

Note that you will need extra quotes if Static Pressure is a Text type field
(not a Number type field):


DoCmd.OpenReport "hydrant report", Printmode, , _
"[Static Pressure] < """ & Me.Number & """"
 

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