DoCmd.OpenReport 
Author Message
 DoCmd.OpenReport

I am using the following from a Form to open a report. I
need to add a From and To Date to this criteria, but am
having trouble with the syntax. I will be allowing input
of a date range to pick up a specific date field in the
Record Source of the Report.

Thanks, Chris

stLinkCriteria = "[ProjectStatus]=" & "'" & Me!
[ProjectStatus] & "'"

DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria



Wed, 12 Oct 2005 02:30:28 GMT  
 DoCmd.OpenReport
stLinkCriteria = "[ProjectStatus]=" & "'" & Me![ProjectStatus] & _
  "' AND [DateField] Between " & Format(Me!StartDate,"\#mm\/dd\/yyyy\#) & _
  " and " &  & Format(Me!EndDate,"\#mm\/dd\/yyyy\#)
'Use this to check your work and when you have a valid looking string
'delete or comment out the next two lines
Debug.Print stLinkCriteria
Stop  
'Switch to the debug window.

DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

You need to construct an SQL where clause as a string without the leading WHERE.

Quote:

> I am using the following from a Form to open a report. I
> need to add a From and To Date to this criteria, but am
> having trouble with the syntax. I will be allowing input
> of a date range to pick up a specific date field in the
> Record Source of the Report.

> Thanks, Chris

> stLinkCriteria = "[ProjectStatus]=" & "'" & Me!
> [ProjectStatus] & "'"

> DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria



Wed, 12 Oct 2005 03:42:09 GMT  
 DoCmd.OpenReport
On Fri, 25 Apr 2003 11:30:28 -0700, "Chris B."

Quote:

>I am using the following from a Form to open a report. I
>need to add a From and To Date to this criteria, but am
>having trouble with the syntax. I will be allowing input
>of a date range to pick up a specific date field in the
>Record Source of the Report.

>Thanks, Chris

>stLinkCriteria = "[ProjectStatus]=" & "'" & Me!
>[ProjectStatus] & "'"

>DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

Chris, use the Between ... And Operator:

Assuming that the 2 input date textboxes are named txtDateOne and
txtDateTwo. The date field on the report is named TheDate.
Change accordingly ...

    stLinkCriteria = "ProjectStatus='" & Me.ProjectStatus _
    & "' AND (TheDate Between #" & Me.txtDateOne & "# And #" _
    & Me.txtDateTwo & "#)"

- Jim



Wed, 12 Oct 2005 04:12:01 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. docmd.openreport

2. Limit DoCmd.OPenReport to print first three pages

3. docmd.OpenReport

4. Opening reports with filters with docmd.openreport

5. Reports Not Maximized on docmd.OpenReport

6. Help with DoCmd.OpenReport

7. Reports - cancel of DoCmd OpenReport not working

8. doCmd.OpenReport-How to call from VB with Parameters

9. Let me restate..DoCmd.OpenReport in acnormal. I only want the first three pages of rpt.

10. Question about 'Docmd.openreport' batch print feature

11. DoCmd.RunCommand acCmdSaveRecord DoCmd.RunCommand acCmdSaveRecord

12. bizarre openreport actions

 

 
Powered by phpBB® Forum Software