Full Version: Searching a form for a record
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
repasky
I am having troulble searching for a record on a form. The form is a subform. The error is on the FindFirst. The message is as follows.

The Microsoft Jet database engine does not recognize 'Forms!frmSAIDEEMain!sfrmHRReq.Form!fldReqID' as a valid field name or expression.

Someone gave me the link http://www.mvps.org/access/forms/frm0031.htm but that did not help. I redid the program and the code is below. I am just trying to search for a record on a form.

Thanks ahead of time. I am getting frustrated at this.

Al



TPrivate Sub Find_Req_Click()
On Error GoTo Err_Find_Req_Click

Dim Criteria As String
Dim FindID As String
Dim MyRs As DAO.Recordset
Dim MyForm As Form

FindID = InputBox("Find Req ID")

Set MyForm = Screen.ActiveForm
Set MyRs = MyForm.RecordsetClone
MyRs.Bookmark = MyForm.Bookmark

'Criteria = "[fldReqID] = """ & FindID & """"
'Forms!frmCoverPage!subInspectForm.Form!FormsUsedID
Criteria = "Forms!frmSAIDEEMain!sfrmHRReq.Form!fldReqID = " & FindID
MsgBox Criteria
MyRs.FindFirst Criteria
MsgBox "after find"

If MyRs.NoMatch Then
MsgBox "Nomatch"
Else
MyForm.Bookmark = MyRs.Bookmark
End If

MyForm.Close
Set MyForm = Nothing
MyRs.Close
Set MyRs = Nothing

Exit_Find_Req_Click:
Exit Sub

Err_Find_Req_Click:
MsgBox Err.Description
Resume Exit_Find_Req_Click

End Sub
mike60smart
Hi

Have you tried in your criteria row the following?

Me!sfrmHRReq.Form.fldReqID

Mike
Jack Cowley
Also, is "sfrmHRReq" the name of the subform CONTROL and not the name of the subform itself? They are not always the same...

hth,
Jack
repasky
"sfrmHRReq" is the name of the subform.

I am going to try the other suggestion.

Al
Jack Cowley
The name of the subform and subform CONTROL may not be the same. Check the name of the subform control on your main form to be sure it is "sfmHRReq"... We may have semantics problem in that the name of the CONTROL may, in fact, be "sfmHRReq" and if it is then that is not the problem..

Jack
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.