Quantcast
Viewing all articles
Browse latest Browse all 21362

data type mismatch in criteria expression error

i have a appointment schedule im getting this error data type mismatch in criteria expression when i try to check if
the cust already has a appointment or the hairdresser is already busy in this hour
need some help
this is my code
Code:

Private Function AppIsOK() As Boolean
    Dim s As String, S1 As String, S2 As String
   
    s = "SELECT * FROM Appointments WHERE " & _
        "AppHair= " & CmbHair.ItemData(CmbHair.ListIndex) & " AND " & _
        "AppDate= #" & MyDate(PckBirth.Value) & "#"
    If Not NewRec Then s = s & " AND AppID<> " & FrmAppointments.LsVw.SelectedItem.Tag
   
    Set rs = CN.Execute(s)
    While Not rs.EOF
        S1 = Right$(rs!AppTimein, 5)
        S2 = Mid$(rs!AppTimeout, 1, 5)
        If (CDate(CmbStart.text) >= CDate(S1) And CDate(CmbStart.text) < CDate(S2)) Or _
            (CDate(CmbEnd.text) > CDate(S1) And CDate(CmbEnd.text) <= CDate(S2)) Then
                MsgBox CmbHair.text & " is already taken", vbInformation, _
                    CmbStart.text & " - " & CmbEnd.text
                AppIsOK = False
                CmbStart.SetFocus
                Exit Function
        End If
        rs.MoveNext
    Wend
       
    s = "SELECT * FROM Appointments, AppHair WHERE " & _
        "AppCust= " & TxtDesc.text & " AND AppID=AppHair AND " & _
        "AppDate= #" & MyDate(PckBirth.Value) & "#"
    If Not NewRec Then s = s & " AND AppID<> " & FrmAppointments.LsVw.SelectedItem.Tag
       
    Set rs = CN.Execute(s)
    While Not rs.EOF
        S1 = Right$(rs!AppTimein, 5)
        S2 = Mid$(rs!AppTimeout, 1, 5)
        If (CDate(CmbStart.text) >= CDate(S1) And CDate(CmbStart.text) < CDate(S2)) Or _
            (CDate(CmbEnd.text) > CDate(S1) And CDate(CmbEnd.text) <= CDate(S2)) Then
                MsgBox "this customer already have a appointment with " & rs!HairName & "!", _
                    vbInformation, CmbStart.text & " - " & CmbEnd.text
                AppIsOK = False
                CmbStart.SetFocus
                Exit Function
        End If
        rs.MoveNext
    Wend
    AppIsOK = True
    End Function

Code:

table name is Appointments

fileds:

AppID Long
AppDate Date/Time
AppCust Text
AppHair Text
AppTimein Text
AppTimeout Text
AppTreatment Text
AppRemarks Text

Code:

now this is the comobbox hours when i want to make a appointment
CmbStart
CmbEnd

tnx for the help

if any more information is needed i will add
regards salsa31

Viewing all articles
Browse latest Browse all 21362

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>