Link to home
Start Free TrialLog in
Avatar of gsilouisvilleic
gsilouisvilleicFlag for United States of America

asked on

Access Runtime Error '3070'

Hi,

I am trying to create a form with 3 search engines, one for each of 3 different tables containing unique Record IDs.  I got the first section of code to work for one of the tables, but on the second, it keeps giving me the Run-time error '3070' saying that the database engine doesn't recognize "Record ID 2" as a valid field name or expression.  I double checked everything and Record ID 2 is what has been assigned to the fields I'm looking at.  Can anyone please assist me with this?

Option Compare Database


Private Sub B_SearchButton_Click()
If IsNull(Me.Txt_ScanRecordID) = False Then
Me.Recordset.FindFirst "[Record ID 1] ='" & Nz(Me.Txt_ScanRecordID, "") & "'"
If Me.Recordset.NoMatch Then
MsgBox "No Record Found", vbOKOnly + vbInformation, "Sorry"
Me.Txt_ScanRecordID.SetFocus
Else

DoCmd.OpenForm "F_Close Locked Location Audit Record", WhereCondition:="[Record ID 1] = '" & Me.Txt_ScanRecordID & "'", OpenArgs:="E"
DoCmd.Close acForm, "F_Search Engine", acSaveNo

End If
End If
End Sub

Private Sub B_SearchButton2_Click()
If IsNull(Me.Txt_ScanRecord2) = False Then
Me.Recordset.FindFirst "[Record ID 2] ='" & Nz(Me.Txt_ScanRecord2, "") & "'"
If Me.Recordset.NoMatch Then
MsgBox "No Record Found", vbOKOnly + vbInformation, "Sorry"
Me.Txt_ScanRecord2.SetFocus
Else

DoCmd.OpenForm "F_Close Putaway Audit Record", WhereCondition:="[Record ID 2] = '" & Me.Txt_ScanRecord2 & "'", OpenArgs:="E"
DoCmd.Close acForm, "F_Search Engine", acSaveNo

End If
End If
End Sub
SOLUTION
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

what is the RecordSource of the form (Property Sheet, Data tab)? If it contains a query(/ies), please post the SQL statement(s) -- if you don't know how to get this, ask - thanks

FindFirst acts on a field name(s) in the RecordSource -- not a control name(s)
Avatar of gsilouisvilleic

ASKER

I had it as a query that only brought down each field (Record ID 2 pulled through) and also tried it as just the table for the record source and it didn't work.
I tried changing it to me![txtRecordID2] and I couldn't make that work either.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial