Question : Why am I getting a data type mismatch error?

When this code runs I get an error that says "data type mismatch in criteria expression".  It's having a problem with this line:

strSQL = "SELECT * FROM tbl_APPTs WHERE CLIENT_ID = '" & Me.CLIENT_ID & "' AND APPT_ID = '" & Me.APPT_ID & "'"

but I'm not sure what the problem is.  Can someone help?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Private Sub cmdCancel_Click()
    Dim message As String
    Dim rstAppt As DAO.Recordset
    Dim strSQL As String
    strSQL = "SELECT * FROM tbl_APPTs WHERE CLIENT_ID = '" & Me.CLIENT_ID & "' AND APPT_ID = '" & Me.APPT_ID & "'"

    Set rstAppt = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
    message = MsgBox("Do you want to delete this appointment?", vbYesNoCancel)
       If message = vbYes Then
          'Delete this appointment
          DoCmd.Close , "", acSaveNo
          rstAppt.Delete
       End If
       If message = vbNo Then
          Me.Dirty = False
       End If
End Sub

Answer : Why am I getting a data type mismatch error?

Are CLIENT_ID and APPT_ID Numeric values? If so, they don't need to be enclosed in quotes:

strSQL = "SELECT * FROM tbl_APPTs WHERE CLIENT_ID = " & Me.CLIENT_ID & " AND APPT_ID = " & Me.APPT_ID
Random Solutions  
 
programming4us programming4us