This code does not work

S

SF

Hi,

I have a button that would execute code below:

Dim stDocName As String
Dim Stg As String

stDocName = "tblHoro"
Stg = "[Dates] BETWEEN #" & Format(Me.DTPFrom, "Short Date") & "# AND #"
& Format(Me.DTPTo, "Short Date") & "#"
DoCmd.OpenReport stDocName, acPreview, , Stg


Once click, a empty report is generated. What is wrong with the above code?

SF
 
A

Allen Browne

1. Try:
Stg = "[Dates] BETWEEN #" & Format(Me.DTPFrom, "mm\/dd\/yyyy") & _
"# AND #" & Format(Me.DTPTo, "mm\/dd\/yyyy") & "#"
That will give you correct results even if your regional settings are
non-US.
More info:
http://allenbrowne.com/ser-36.html

2. If this a bound form, is the record saved?

3. Is there something else limiting the report?
- Other criteria in its query?
- Calculated criteria that can be misunderstood:
http://allenbrowne.com/ser-45.html
- Criteria on nulls (e.g. where the Dates field is blank):
http://allenbrowne.com/casu-02.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top