View Full Version : Recordset Find problem. Help much appreciated


Sausagefingers
11-03-2008, 05:39 AM
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.

Rabbie
11-03-2008, 06:02 AM
If the field ordNum is actually a number field then try removing the ' characters

MSAccessRookie
11-03-2008, 06:04 AM
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

Sausagefingers
11-03-2008, 11:43 PM
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!

Rabbie
11-04-2008, 12:21 AM
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