Can't use Find error (1 Viewer)

XLEAccessGuru

XLEGuru
Local time
Today, 16:17
Joined
Nov 17, 2006
Messages
65
I have code behind a form that looks for missing data. When it finds missing data in the recordset, it finds the record on the form that matches the record ID in the recordset. It has worked fine until now. Nothing has really changed but all of a sudden I'm getting error # 2137 "You can't use find or replace now."

What is perplexing is that I'm not using find/replace to begin with - i'm using the 'findrecord' method. Secondly, this same code has worked perfectly until now.

Here is where it's erroring out. The variable "ProfileRecordID" is set prior to these lines of code and is set on the current record in the open recordset. The error occurs on "DoCmd.FindRecord iProfileID, , , , True".

Code:
If IsNull(rec("Financial Class")) Then
            MsgBox "'Financial Class' " & msg, vbExclamation, VAL_ERR_MSG
            rec.Close
            DoCmd.FindRecord iProfileID, , , , True 'find record that needs to be corrected
            DoCmd.GoToControl ("cboFinClass") 'go to field that needs to be corrected
            Me.cboFinClass.Dropdown
            Exit Sub

Any and all ideas welcome and appreciated!
 

wazz

Super Moderator
Local time
Tomorrow, 04:17
Joined
Jun 29, 2004
Messages
1,711
maybe nothing new but:

Error Description: You can't use Find or Replace now. The fields are not searchable due to one of the following:* The fields are controls (such as buttons or OLE objects).* The fields have no data.* There are no fields to search.

so i would guess that the variable or something in the rset is not available for some reason. iow, the problem is occuring before the line that gives the error. step through and check the values/variables etc.

from msdn: The FindRecord method does not return a value indicating its success or failure. To determine whether a value exists in a recordset, use the FindFirst, FindNext, FindPrevious or FindLast method of the Recordset object. These methods set the value of the NoMatch property to True if the spcified value is not found.

also, i think "You can't use Find or Replace" doesn't just apply to "Find and Replace" but to all 'find' methods like FindFirst, etc.
 

XLEAccessGuru

XLEGuru
Local time
Today, 16:17
Joined
Nov 17, 2006
Messages
65
thanks wazz. for some reason, the form was losing the focus resulting in the error. I just added a "Me.Setfocus" command that resolves the error.

Thanks! :)
 

Users who are viewing this thread

Top Bottom