Link to home
Start Free TrialLog in
Avatar of Nancy Therrien
Nancy TherrienFlag for Canada

asked on

Ms Access VBA Query with Date

Good Morning all,

I'm having a problem with one part of my query.  It seems to work fine but when it print my report, no data on it.  It is surely cause by the date criteria cause if I change it to a single Date >="" it work.

I have attached the sfilter result.

Please help.

Thanks in advance.


'This is calculating to have only the week before, this is working

dtDebut = DateAdd("d", -(DatePart("w", DATE, vbMonday) + 7 + (7 * nbrWeek)), DATE)

    dtFin = DateAdd("d", -(DatePart("w", DATE, vbMonday)), DATE)


Do Until rs.EOF = True
           With rs
            NO_JOB = !NO_JOB
           
            sfilter = "[No_Job]=" & !NO_JOB & " AND [DATE]>=" & dtDebut & " AND [DATE]<=" & dtFin
           
            stDocName = "rpt_Temps Job Particulier sans critere"
            DoCmd.OpenReport stDocName, acViewNormal, , sfilter
          End With
    rs.MoveNext
Loop
sfilter.jpg
ASKER CERTIFIED SOLUTION
Avatar of Nancy Therrien
Nancy Therrien
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rey Obrero (Capricorn1)
change

sfilter = "[No_Job]=" & !NO_JOB & " AND [DATE]>=" & dtDebut & " AND [DATE]<=" & dtFin

with

   sfilter = "[No_Job]=" & !NO_JOB & " AND [DATE]>=#" & dtDebut & "# AND [DATE]<=#" & dtFin & "#"