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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table Search from a Form

Status
Not open for further replies.

CassandraB

Technical User
Feb 23, 2003
4
0
0
US
If someone could be so kind as to helping me out with a problem I am having. Here is my situation:
I have one complete table and I would like to have 2 combo boxes on my form (for searching purposes).
The first combo would have a dropdown of road names and when one is chosen, the second combo box ‘location’, would show all pavement marker locations along that road that was chosen from the first box. Then I would pick the specific location from that second combo and it will take me to the specific record in my table. I would then be able to view the remaining fields as they would all show up in my form when the location is selected.
I have checked previous similar questions asked in this forum but could not quite figure it out. I am a beginner and need simple guidance. I appreciate anyone who can help me see the light and will be forever grateful to you for it! Thank You, Cassie.
 
Hi,

Maybe you can try this.
In the afterupdate event from the first combobox you add code to set the second combo's rowsource object:

i.e.
Private Sub cmdStreet_AfterUpdate()
Me.cmdLocation.RowSource = "SELECT tblStreets.id, tblStreets.location FROM tblStreets WHERE (((tblStreets.id)=" & me.cmdStreet & "));
me.cmdlocation.refresh
end sub

The select statement should make sure that only location markers for the selected street are shown. Of course this depends on the way you created your data structure.

In the after update of the second combo box you can look for the correct record and refresh the form to show the correct record.

Private Sub cmdLocation_AfterUpdate()
me.recordsetclone.findfirst = "id = " & me.cmdLocation
Me.Bookmark = Me.RecordsetClone.Bookmark
end sub

Here ID should be exchanged by the primary key that identifies the record you want.

If you need more help you have to give some details about the settings of you comboboxes (fieldnames etc).

I hope this helps. Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top