Open Date range Dialog Box From Report

M

Mrstacy

Any help is appreciated. When I use the code similar to the Northwind
example, the report does not open all the way. the heading shows up,
but the screen is gray. Thanks in Advance.

Access 2003
Windows XP

This code is for the Report Open event:

Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_ReportOpen

blnOpening = True

DoCmd.OpenForm "Frm_Date_Range", , , , , acDialog

If Not CurrentProject.AllForms("Frm_Date_Range").IsLoaded Then
Cancel = True
End If

blnOpening = False


Exit_ReportOpen:
Exit Sub

Err_ReportOpen:
MsgBox Err.Description
Resume Exit_ReportOpen
 
G

Graham Mandeno

Hi Mrstacy

You do not appear to be doing anything with the values that have been
selected on Frm_Date_Range.

I'm guessing you need to do something like this:

If CurrentProject.AllForms("Frm_Date_Range").IsLoaded Then
With Forms("Frm_Date_Range")
Me.Filter = "[DateField] between " _
& Format(!txtStartDate, "\#mm/dd/yyyy\#" _
& " and " & Format(!txtEndDate, "\#mm/dd/yyyy\#"
Me.FilterOn = True
End With
Else
Cancel = True
End If
 
M

Mrstacy

I do use the date ranges in a query. The query is the basis of a
report. My goal is when a person clicks on a report, the form opens
to enter the date range. Now when they click on the report, all they
see is a grayed out form. They cannot enter date ranges.
Hi Mrstacy

You do not appear to be doing anything with the values that have been
selected on Frm_Date_Range.

I'm guessing you need to do something like this:

If CurrentProject.AllForms("Frm_Date_Range").IsLoaded Then
    With Forms("Frm_Date_Range")
        Me.Filter = "[DateField] between " _
            & Format(!txtStartDate, "\#mm/dd/yyyy\#" _
            & " and " & Format(!txtEndDate, "\#mm/dd/yyyy\#"
        Me.FilterOn = True
    End With
Else
     Cancel = True
End If
--
Good Luck  :)

Graham Mandeno [Access MVP]
Auckland, New Zealand




Any help is appreciated.  When I use the code similar to the Northwind
example, the report does not open all the way.  the heading shows up,
but the screen is gray.  Thanks in Advance.
Access 2003
Windows XP
This code is for the Report Open event:
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_ReportOpen
   blnOpening = True
   DoCmd.OpenForm "Frm_Date_Range", , , , , acDialog
       If Not CurrentProject.AllForms("Frm_Date_Range").IsLoadedThen
            Cancel = True
       End If
   blnOpening = False
Exit_ReportOpen:
   Exit Sub
Err_ReportOpen:
   MsgBox Err.Description
   Resume Exit_ReportOpen- Hide quoted text -

- Show quoted text -
 

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