Dialogue form for a report

jamiecalvert

Registered User.
Local time
Today, 01:20
Joined
Jul 10, 2002
Messages
10
I have a report based upon a query. I did have separate start & end date prompts for the date range for the report but after seeing a report dialogue form in Northwind & some example databases felt this would be more helpful to users. It has a Start & End date boxes & a preview key.

I set up the dialogue form & made sure the date parameters tied in with the query. In the query I have the following criteria:
>=[forms]![Report Date Range]![BeginDate] And <=[forms]![Report Date Range]![EndDate]

In the report I entered the follwing code for on 'Open', 'Close' & 'No data':

Option Compare Database

Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is no data for this report. Cancelling report..."
Cancel = -1
End Sub
Private Sub Report_Close()
DoCmd.Close acForm, "Report Date Range"
End Sub
Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Report Date Range", , , , , acDialog, "Written Business By Advisor Report"
If Not IsLoaded("Report Date Range") Then
Cancel = True
End If
End Sub

When I open the report I am being told there is a complie error and a Sub or Function not defined. 'IsLoaded' and 'Private Sub Report_Open(Cancel As Integer)' are highlighted.

Could someone advise where I am going wrong.

Thanks.
 
You have a moudule missing! Make a new module and put this code there, then you should be OK:)

Option Compare Database

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function
 
Thanks for getting back. I incorporated the IsLoaded function and everything was working fine on all the reports I used this for. I then started using for Charts. The first was fine and then after the second I get an error message on no only the charts but all of the reports I had been working on. The message was:

Complie error. Ambigious name detected: Report_NoData

I also get this message when opening the report dialogue box.

The IsLoaded code I used was:
Private Sub Report_NoData(Cancel As Integer)
MsgBox "There is no data for this report. Canceling report..."
Cancel = -1
End Sub
Private Sub Report_Close()
DoCmd.Close acForm, "Report Date Range"
End Sub
Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "Report Date Range", , , , , acDialog, "Written Commission Chart"
If Not IsLoaded("Report Date Range") Then
Cancel = True
End If
End Sub

The event procedure code was as stated in my earlier note, save for the name change for each report.

I have been looking at this for a few hours, but I am stumpted. Any help/ideas would be appreciated. Thank you.
 
Since I posted my last message, I have removed the Chart reports and the other reports all worked OK. I have now re-built my charts and everything is ok (touch wood).
Still no idea why I had the problem. It would be good to know if anyone has any ideas.
 

Users who are viewing this thread

Back
Top Bottom