docmd.openreport 
Author Message
 docmd.openreport

I am trying to have VBA prompt the viewer of a report for
info in the underlying query called qs_main.  I am getting
prompts for the data but nothing is happening to these
prompts.  Any suggestions as to why my condition section
in my docmd.openreport doesn't work?

Private Sub Report_Open(Cancel As Integer)
 Dim MonthOfReport As Integer
 Dim YearofReport As Integer
 MonthOfReport = InputBox("Enter month of report." & _
                 Chr(13) & _
                 "Month should be in numeric format" & _
                 Chr(13) & _
                 "i.e. 12")
 YearofReport = InputBox("Enter year of report." & _
                 Chr(13) & _
                 "Year should be in numeric format" & _
                 Chr(13) & _
                 "i.e. 2001")

 DoCmd.OpenReport "R_main", acViewPreview, , _
 ([QS_main].[monthofdate] = MonthOfReport) And _
 ([QS_main].[yearofdate] = YearOfReport)

 End Sub



Sat, 09 Oct 2004 03:33:15 GMT  
 docmd.openreport
The WhereCondition argument must be provided as a character string.  Try

    DoCmd.OpenReport "R_main", acViewPreview, , _
        "([QS_main].[monthofdate] = " & MonthOfReport & _
        ") And ([QS_main].[yearofdate] = " & YearOfReport & ")"

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(to reply via e-mail, remove NOSPAM from address)


Quote:
> I am trying to have VBA prompt the viewer of a report for
> info in the underlying query called qs_main.  I am getting
> prompts for the data but nothing is happening to these
> prompts.  Any suggestions as to why my condition section
> in my docmd.openreport doesn't work?

> Private Sub Report_Open(Cancel As Integer)
>  Dim MonthOfReport As Integer
>  Dim YearofReport As Integer
>  MonthOfReport = InputBox("Enter month of report." & _
>                  Chr(13) & _
>                  "Month should be in numeric format" & _
>                  Chr(13) & _
>                  "i.e. 12")
>  YearofReport = InputBox("Enter year of report." & _
>                  Chr(13) & _
>                  "Year should be in numeric format" & _
>                  Chr(13) & _
>                  "i.e. 2001")

>  DoCmd.OpenReport "R_main", acViewPreview, , _
>  ([QS_main].[monthofdate] = MonthOfReport) And _
>  ([QS_main].[yearofdate] = YearOfReport)

>  End Sub



Sat, 09 Oct 2004 05:10:57 GMT  
 
 [ 2 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