My code:
Private Sub cboOpportunity_GotFocus()
Dim rst As DAO.Recordset
'Get the database and Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblPipeLineInput")
'Search for the first matching record
rst.FindFirst "[StationID] = txtStationID"
'Check the result
If rst.NoMatch Then
MsgBox "Record not found."
Else
Exit Sub
End If
rst.Close
Set rst = Nothing
Set dbs = Nothing
End Sub
Result:
Can somebody explain where I am going wrong? As I have tried all sorts of alternatives. I am simply looking to see if there are any records in the table"tblpipeLineInput" with an ID equal to that contained in a textbox "txtStationID"
Thanks
Private Sub cboOpportunity_GotFocus()
Dim rst As DAO.Recordset
'Get the database and Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblPipeLineInput")
'Search for the first matching record
rst.FindFirst "[StationID] = txtStationID"
'Check the result
If rst.NoMatch Then
MsgBox "Record not found."
Else
Exit Sub
End If
rst.Close
Set rst = Nothing
Set dbs = Nothing
End Sub
Result:
Can somebody explain where I am going wrong? As I have tried all sorts of alternatives. I am simply looking to see if there are any records in the table"tblpipeLineInput" with an ID equal to that contained in a textbox "txtStationID"
Thanks