Recordset Find problem. Help much appreciated

Sausagefingers

Registered User.
Local time
Today, 08:40
Joined
Dec 14, 2006
Messages
51
Hi,
I have a problem. Below I've posted two separate code snippets. Both are intended to run on separate AfterUpdade() events on the same form. As such, I have two (unbound) comboboxes on the form to retrieve the data. The first one works perfectly. However, the second one won't work at all:

Me.RecordsetClone.FindFirst "[Name] = '" & Me![delName] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark

And;

Me.RecordsetClone.FindFirst "[OrderNumber] = '" & Me![ordNum] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark

I would like to be able to search the recordset either by name or by order number. Can anyone point out why I'm having this problem? All the fields in the table are 'Text' datatype. I can't understand why the second snippet won't work.

Thanks in advance.
 
If the field ordNum is actually a number field then try removing the ' characters
 
Hi,
I have a problem. Below I've posted two separate code snippets. Both are intended to run on separate AfterUpdade() events on the same form. As such, I have two (unbound) comboboxes on the form to retrieve the data. The first one works perfectly. However, the second one won't work at all:

Me.RecordsetClone.FindFirst "[Name] = '" & Me![delName] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark

And;

Me.RecordsetClone.FindFirst "[OrderNumber] = '" & Me![ordNum] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark

I would like to be able to search the recordset either by name or by order number. Can anyone point out why I'm having this problem? All the fields in the table are 'Text' datatype. I can't understand why the second snippet won't work.

Thanks in advance.

  • Although I doubt it is related to your problems, I usually use a different form of the Control name in these situations.
Me.RecordsetClone.FindFirst "[OrderNumber] = '" & Me.ordNum & "'"
  • You might want to verify that the Control Field ordNum is defined as a string, and not some type of Number, (or as General, which could be interpreted as a number).
    • If it is defined as some type of Number, then remove the quotes. If it is defined as General, then adding cstr() to the call could help.
Me.RecordsetClone.FindFirst "[OrderNumber] = & Me.ordNum
    • If it is defined as General, then adding cstr() to the call could help.
Me.RecordsetClone.FindFirst "[OrderNumber] = '" & cstr(Me.ordNum) & "'"


Looks like Rabbie beat me to replying (again), and agrees with me regarding what to do if the Control Field is a Number
 
Last edited:
As usual, you guys Rock! :D

I'm still not crystal clear on the reason this problem has given me so much grief (having no formal VB training can be a pain sometimes).:mad:

The single quotes are removed as you have suggested. Now all is well!
 
As usual, you guys Rock! :D

I'm still not crystal clear on the reason this problem has given me so much grief (having no formal VB training can be a pain sometimes).:mad:

The single quotes are removed as you have suggested. Now all is well!
Glad to have been of help
 

Users who are viewing this thread

Back
Top Bottom