gsilouisvilleic
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.SetFoc us
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.SetFocu s
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
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
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.SetFoc
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)
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.SetFocu
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
I tried changing it to me![txtRecordID2] and I couldn't make that work either.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
FindFirst acts on a field name(s) in the RecordSource -- not a control name(s)