Schedule and appointment

Dim strDate As String
Dim strSQL As String
strDate = Format(Me.txtAppointDate, strcJetDate)
strSQL = "SELECT * FROM tblAppointments WHERE tblAppointments.AppointDate > " & strDate
Debug.Print strSQL
SELECT * FROM tblAppointments WHERE tblAppointments.AppointDate > #08/08/2020#
Well I would expect that would work?, the syntax looks correct to me.?
 
Could your appointment date contain a time component? It so, then you may find my YouTube video helpful:-

 
Well I would expect that would work?, the syntax looks correct to me.?
Unfortunately No. I get the same Runtime Error '3075': Syntax Error in Date query expression DoctorsID=1 AND AppointDate=#08.08.2020'., when I try to assign appointment time. Sorry, for taking up your time I might have made somewhere mistakes.
 
You have no closing # on the date?
Whys is that, when the Debug.Print shows a closing #?
 
Here is the code.
Code:
    Dim strDate As String
    Dim strSQL As String
    strDate = Format(Me.txtAppointDate, strcJetDate)
    strSQL = "SELECT * FROM tblAppointments  WHERE tblAppointments.AppointDate > " & strDate
    
    sSQL = "SELECT DoctorsID, AppointDate, AppointTime"
    sSQL = sSQL & " FROM qrySubformAppoints"
    sSQL = sSQL & " WHERE DoctorsID= " & Me.ID & _
                            " AND AppointDate=#" & Me.txtAppointDate & "#"
    Set oRS = CurrentDb.OpenRecordset(sSQL)
 
Well I do not know why that closing #is not being shown on the error, but as you already have Me.txtAppointDate in the format you need, why are you not using that in the second sql string? :(

Plus it is showing up as in the format of your regional settings?

Are we not learning anything here?

I'm off to bed now, so if you are still having problems and noone else jumps ins, we'll try to continue tomorrow.
 

Users who are viewing this thread

Back
Top Bottom