Hello: I would like to open different forms, based on dates in an unbound combo box on a different form. So, open a form to specify dates and then click to open a form with that date range of records. It is called from the form that is to open.
I currently used something I came across online, to open reports, but I can't seem to do the same thing with opening a form. What is in the following that is stopping it from working with opening a form? The result is that the it first opens the query specification. "enter Paramater Value", then opens the unbound form.
In Module:
Option Compare Database
Option Explicit
Public bInReportOpenEvent As Boolean ' Is report in the Open event?
Form where I choose dates on an unbound form:
Private Sub Form_Open(Cancel As Integer)
If Not bInReportOpenEvent Then
'If we're not called from the report
MsgBox "For use from the Statistics All Report only", vbOKOnly
Cancel = True
End If
Form_Open_Exit:
Exit Sub
End Sub
On the report that I want to open:
Private Sub Report_Open(Cancel As Integer)
' Set public variable to true to indicate that the report
' is in the Open event
bInReportOpenEvent = True
' Open FrmCrosstab2
DoCmd.OpenForm "FrmStatsAll", , , , , acDialog
'If the user closed the form (cancelled)
If Not IsFormLoaded("FrmStatsAll") Then
Cancel = True
End If
' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub
Thank you for any help. Sophia
I currently used something I came across online, to open reports, but I can't seem to do the same thing with opening a form. What is in the following that is stopping it from working with opening a form? The result is that the it first opens the query specification. "enter Paramater Value", then opens the unbound form.
In Module:
Option Compare Database
Option Explicit
Public bInReportOpenEvent As Boolean ' Is report in the Open event?
Form where I choose dates on an unbound form:
Private Sub Form_Open(Cancel As Integer)
If Not bInReportOpenEvent Then
'If we're not called from the report
MsgBox "For use from the Statistics All Report only", vbOKOnly
Cancel = True
End If
Form_Open_Exit:
Exit Sub
End Sub
On the report that I want to open:
Private Sub Report_Open(Cancel As Integer)
' Set public variable to true to indicate that the report
' is in the Open event
bInReportOpenEvent = True
' Open FrmCrosstab2
DoCmd.OpenForm "FrmStatsAll", , , , , acDialog
'If the user closed the form (cancelled)
If Not IsFormLoaded("FrmStatsAll") Then
Cancel = True
End If
' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub
Thank you for any help. Sophia