End user input to pull a specific record

jwf

Registered User.
Local time
Today, 10:01
Joined
Dec 5, 2012
Messages
18
This is probably Acces 101 but I cant figure it. I want to use a Form or Report to have the end user enter say a Customer # or the Customer Last Name and then have Access pull and display that record so that the end user can than print all the saved information from that record.
 
In a form linked to your table, create a textbox called txtFilter. Create a button called cmdFilter. Use the OnClick event of cmdFilter and set it to something like this:
Code:
If IsNull Me.txtFilter Then
Me.FilterOn = False
Else
Me.Filter = "[CustomerNo] = " & Me.txtFilter
Me.FilterOn = True
End If
The value I used for Me.Filter assumes CustomerNo is a number. If you have something like CustomerLastName, where CustomerLastName is a string, you would replace that line with something like:
Code:
'Strings need to be enclosed in single quotes (') or double quotes (")
Me.Filter = "[CustomerNo] = '" & Me.txtFilter & "'"
To print out a report with those records, create a button on the same form called cmdPrint. In the OnClick event property, add the following code:
Code:
DoCmd.OpenReport "rptName", acViewNormal, , "[CustomerNo] = " & Me.txtFilter
 
Great help. Thank you
 

Users who are viewing this thread

Back
Top Bottom