Combo Box

  • Thread starter Thread starter Old Music Lover
  • Start date Start date
O

Old Music Lover

I have a combo box with the following "after update" code. I get a Type
Mismatch message on the

Set MeClone = Me.RecordsetClone statement.

Any clues as to what I have done wrong? It also does not recognize the
NoMatch on the MeClone.

Private Sub NAME_SELECT_Change()
Dim SearchValue As String
Dim MeClone As Recordset
Set MeClone = Me.RecordsetClone
Let SearchValue = Me![NAME_SELECT].Value
MeClone.Find "[EMPLID] = " & SearchValue
If Not MeClone.NoMatch Then
Me.Bookmark = MeClone.Bookmark
End If
MeClone.Close
End Sub
 
Try this instead (in AfterUpdate, not Change):

Private Sub NAME_SELECT_AfterUpdate()
Me.RecordsetClone.FindFirst "[EMPLID] = " & Me![NAME_SELECT]
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

This assumes that EMPLID is a numeric value.
 
I have a combo box with the following "after update" code. I get a Type
Mismatch message on the

Set MeClone = Me.RecordsetClone statement.

Any clues as to what I have done wrong? It also does not recognize the
NoMatch on the MeClone.

Private Sub NAME_SELECT_Change()
Dim SearchValue As String
Dim MeClone As Recordset
Set MeClone = Me.RecordsetClone
Let SearchValue = Me![NAME_SELECT].Value
MeClone.Find "[EMPLID] = " & SearchValue
If Not MeClone.NoMatch Then
Me.Bookmark = MeClone.Bookmark
End If
MeClone.Close
End Sub

A couple of things. In A2000 and 2002 Access defaults to setting a
reference to the ADO library - but not the DAO library; BOTH these
libraries have Recordset objects but they are *different* objects. A
Form's RecordsetClone is a DAO recordset.

Try Dim MeClone AS DAO.Recordset

You may need to use Tools... References and scroll down and check the
Microsoft DAO x.xx Object Library reference.

The other issue is your Let statement - the Let keyword is not needed,
nor is the .Value (which is the default).


John W. Vinson[MVP]
 
Back
Top