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

Select Record Using Combo-Box values

Status
Not open for further replies.

Vidar13

IS-IT--Management
Apr 4, 2001
90
US
Is there a quick and dirty way to select a record on a form from the value selected in a combo-box within that form?

The combo box is based on rowsource select of the same table.
 
Yes there is. There are really two way of using the combobox. If it represents many records you would probably want to filter the data and only represent the matching items (See LCN_SELECTED or NIIN_SELECTED below). If it represents a single item and you want to merely move the focus to that record you would want to use bookmarks (See CPN_SELECTED below).

This code is based on selection from an option box which, in turn, uses the data in the combobox to either filter or find a record.

Steve King

Select Case Me.fraQuickFindType
Case CPN_SELECTED
Set rst = Me.RecordsetClone
rst.FindFirst "[CP/N]='" & Me.cboQFind.Column(0) _
& "' And [Cage]='" & Me.cboQFind.Column(1) & "'"

If rst.NoMatch Then
'
Else
Me.Bookmark = rst.Bookmark
End If 'If rst.NoMatch Then

rst.Close

Case LCN_SELECTED
Me.Filter = "LCN='" & Me.cboQFind & "'"
Me.FilterOn = True
Case NIIN_SELECTED
Me.Filter = "NIIN='" & Me.cboQFind & "'"
Me.FilterOn = True
End Select 'Select Case Me.fraQuickFindType

Growth follows a healthy professional curiosity
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top