Schedule and appointment (1 Viewer)

Gasman

Enthusiastic Amateur
Local time
Today, 14:02
Joined
Sep 21, 2011
Messages
14,042
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.?
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:02
Joined
Jul 9, 2003
Messages
16,244
Could your appointment date contain a time component? It so, then you may find my YouTube video helpful:-

 

teddy1

New member
Local time
Today, 15:02
Joined
Jul 26, 2020
Messages
12
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.
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:02
Joined
Sep 21, 2011
Messages
14,042
You have no closing # on the date?
Whys is that, when the Debug.Print shows a closing #?
 

teddy1

New member
Local time
Today, 15:02
Joined
Jul 26, 2020
Messages
12
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)
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:02
Joined
Sep 21, 2011
Messages
14,042
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

Top Bottom