Error 2105 - can't go to specified record - makes sense
Error 3018 - could not find field - this may indicate another issue also needs resolving
I'm going to offer 3 solutions, one of which is similar to the reply by kudos
1. Use error handling:
Code:
Private Sub cmdfrmLogTPAID_Click()
On Error GoTo Err_Handler
'Your open form code goes here
DoCmd.OpenForm "frmLogTPAID",,,"your filter criteria here"
Exit_Handler:
Exit Sub
Err_Handler:
If err=2105 or err=3018 Then
MsgBox "This record does not exist."
Else
MsgBox "Error " & err & " in cmdfrmLogTPAID_Click procedure"
End If
GoTo Exit_Handler
End Sub
2. Check record exists
Code:
Private Sub cmdfrmLogTPAID_Click()
On Error GoTo Err_Handler
If DCount("*","qryLogIscOID","ID = " & your filter criteria)>0 Then
'Your open form code goes here
DoCmd.OpenForm "frmLogTPAID",,,"ID = " & your filter criteria
Else
MsgBox "This record does not exist."
End If
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox "Error " & err & " in cmdfrmLogTPAID_Click procedure"
GoTo Exit_Handler
End Sub
3. Add a combo box to the form listing all records - use your qryLogIscOID as the row source
Then use the combo selection as the record source for the form
All should work. In my opinion, method 1 is OK; 2 is better; 3 is best