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

Using combo box to look up a record

Status
Not open for further replies.

add39

Technical User
Jul 24, 2003
19
US
I would like my 'Initiative' combo box (cboInit)to look up the appropriate record once an initiative is chosen. How do I go about doing that?
 
add,

code::::::
Private Sub Combo35_Click()
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
If rs.EOF And rs.BOF Then
MsgBox "No records"
rs.Close
Set rs = Nothing
End If
rs.MoveLast
rs.MoveFirst

Do While Not rs.EOF

If Me.Combo35 = rs("LocationAddress") Then

Me.Bookmark = rs.Bookmark
Exit Do
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing

End Sub

stop code:::

rollie@bwsys.net

p.s. if this helps say so by clicking tips above
 
The code isn't exactly working...it keeps returning 0 values for every field instead of looking up the actual record.
 
put some msgbox's at strategic locations. Or send me a zipped copy of the mdb and I will look at it.

rollie@bwsys.net
 
When running the procedure this is the line that is giving me a problem:

If Me.Combo35 = rs("LocationAddress") Then

What should be going into these fields?
 
You have to put the name of your field in there. LocationAddress is the name of mine.

Rollie E
 
Why in the name of Bill Gates would anyone try to make something so complicated when Access has a built in Wizard that will do the job in about two minutes?

Base your form on a query that shows the fields of the record that you want to display. Place a combobox on the form. The Access Wizard will ask you what you want to do with the combobox value. The third choice is something like "Find a record on my form based on the value I selected". Select this, click "Next", and choose the field that contains the "Initiative". Follow the wizard's instruction (I think you just click "Finish" to complete it).

Hope this helps.

The Missinglinq

"It's got to be the going,
not the getting there that's good!"
-Harry Chapin
 
I've already created the combo box, and its value changes based on the value of another combo box, which took me a long time to complete, so now I can't go back and change it. I was just wondering if theres a simple way to do it at this juncture.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top