Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Table and Display Result on Form

Status
Not open for further replies.

drm184

MIS
May 25, 2001
35
0
0
US
Here's what I'm asking for help doing: I have a search selection on my switchboard. When I click on a category to search I want to be able to enter a parameter (such as job number which is the primary key), and then have the form display only that record. I'm not sure how to go about this. Thanks for any and all help.
 
You don't mention what you are opening on your switch board when you click on Category? Is a form opening with a list box are you using a combo box? I'm sure your not trying to type a number in from memory?

Here is what I would try. Create an unbound form with a list box and populate it with the data you want to pull records up for. This can be accomplised by handling the data to be filled on the on Open event of the form by doing some SQL

Private Sub Form_Load()
With me.Category 'the name of the list box
.RowSource = _
"SELECT DISTINCT Category FROM MyMainTable " & _
"WHERE Category IS NOT NULL"
.LimitToList = true 'if using a combo box
End With
End Sub

Now you have your criteria. So now you need to display it. On the top of the form you just created add the following
Dim strFilter as string

Now on the double-click event, or after update event or for that fact whatever event you want to fire this code on of the list box add the following code.

strFilter = Me("Category")
DoCmd.OpenForm "frmIwanttodisplayhere", , , "nameof tableholdingmydatahere= " & strFilter

Good luck. Life's a journey enjoy the ride...

jazzz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top