I have three tables with the exact same data fields and data types. I am trying to create a search form using one combo box for three subforms. I tried changing the String to Integer but I always end up with the same error: "Data type mismatch on criteria expression". What am I doing wrong here.
Private Sub cboAlarmSearch_AfterUpdate()
Dim SpotAlarm As String
Dim ProgressAlarm As String
Dim FinalAlarm As String
Dim strAlarmCriteria As String
If IsNull(Me.cboAlarmSearch) Or Me.cboAlarmSearch = "" Then
MsgBox "Please choose an Alarm to search.", vbOKOnly, "Alarm Required"
Else
strAlarmCriteria = Me.cboAlarmSearch.Value
'Alarm search for Spot
SpotAlarm = "Select * FROM tblSpot WHERE ([Alarm] = '" & strAlarmCriteria & "')"
Me.frmSpotSearchSubform.Form.RecordSource = SpotAlarm
Me.frmSpotSearchSubform.Form.Requery
'Alarm search for Progress
ProgressAlarm = "Select * from tblProgress WHERE ([Alarm] = '" & strAlarmCriteria & "')"
Me.frmProgressSearchSubform.Form.RecordSource = ProgressAlarm
Me.frmProgressSearchSubform.Form.Requery
'Alarm search for Final
FinalAlarm = "Select * from tblFinal WHERE ([Alarm] = '" & strAlarmCriteria & "')"
Me.frmFinalSearchSubform.Form.RecordSource = FinalAlarm
Me.frmFinalSearchSubform.Form.Requery
End If
End Sub