Using combo box for entry

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to use a combo box to access a specific record in a table. The
record has 3 keys and an index made up of the 3 keys. I'm trying to get the
combo box to display concatenation of the 3 keys. Can't I use the compound
index to do this? If so, how?

Thanks
 
I'm trying to use a combo box to access a specific record in a table. The
record has 3 keys and an index made up of the 3 keys. I'm trying to get the
combo box to display concatenation of the 3 keys. Can't I use the compound
index to do this? If so, how?

No. Indexes are pretty much hidden objects - they don't let you
extract the values of fields, etc.

You should be able to create a Combo Box returning the three fields in
three columns of the combo; in the Combo's AfterUpdate event do
something like

Dim strSQL As String
strSQL = "[FieldA] = " & Me!cboMyCombo.Column(0) _
& " AND [FieldB] = '" & Me!cboMyCombo.Column(1) & "'" _
& " AND [FieldC] = " & Me!cboMyCombo.Column(2)
Me.Filter = strSQL
Me.FilterOn = True

This assumes that the three fields are in the first three columns
(zero based) of the combo, and that FieldB is Text and FieldA and
FieldC are numeric.

Or, you could use the Form's RecordsetClone:

Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "[FieldA] = " & Me!cboMyCombo.Column(0) _
& " AND [FieldB] = '" & Me!cboMyCombo.Column(1) & "'" _
& " AND [FieldC] = " & Me!cboMyCombo.Column(2)
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If


John W. Vinson[MVP]
 
Back
Top