runtime error 13

P

PC

I have the typical code for doing a record look up ...

Private Sub Combo156_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Combo156], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub

The problem is if I backspace an entry in the combo box and move to another
field it considers the entry a type mismatch. The field appears blank when
this happens, but apprently the control thinks otherwise. How can I prevent
this from happening?

Thanks,

Paul
 
O

Ofer Cohen

Assuming by your code, using str, the search is on a string type field. In
that case you need to add a single quote before and after the text

rs.FindFirst "[ID] = '" & Str(Nz(Me![Combo156], 0)) & "'"


In any case, check this link for a search example on a form

http://www.databasedev.co.uk/text_search.html
 
P

PC

Sorry this didn't work, the field is actually numeric. The row source is a
query bound to column 1 which is a numeric ID and displays column 2 which has
a person’s concatenated name. Unfortunately adding this code still produced
error 13 type mismatch.

Ofer Cohen said:
Assuming by your code, using str, the search is on a string type field. In
that case you need to add a single quote before and after the text

rs.FindFirst "[ID] = '" & Str(Nz(Me![Combo156], 0)) & "'"


In any case, check this link for a search example on a form

http://www.databasedev.co.uk/text_search.html

--
Good Luck
BS"D


PC said:
I have the typical code for doing a record look up ...

Private Sub Combo156_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Combo156], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub

The problem is if I backspace an entry in the combo box and move to another
field it considers the entry a type mismatch. The field appears blank when
this happens, but apprently the control thinks otherwise. How can I prevent
this from happening?

Thanks,

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top