B
Bill
I created a parameter for to collect three pices of information for a report:
1. Employee name
2. start date
3. end date
I entered the code according to the microsoft access online website
(http://office.microsoft.com/en-us/access/HA011170771033.aspx?pid=CH063653181033)
I can run the report and the dialog box will come up, but the 'OK' and
'cancel' buttons don't work. It's just frozen.
Since I know you will be asking for the VBA coding here it is...I put the
name for each code in CAPS...
FOR THE FORM (OnOpen):
Option Compare Database
Private Sub Cancel_Click()
DoCmd.Close
End Sub
Private Sub Form_Open(Cancel As Integer)
If Not bInReportOpenEvent Then
' If we're not called from the report
MsgBox "For use from the Evals by Employee Name (date range) Report
only", _
vbOKOnly
Cancel = True
End If
Form_Open_Exit:
Exit Sub
End Sub
Private Sub OK_Click()
Me.Visible = False
End Sub
FOR THE REPORT (OnOpen):
Option Compare Database
Private Sub Report_Close()
DoCmd.Close acForm, "Employee Date Range Dialog"
End Sub
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 Sales By Category Dialog
DoCmd.OpenForm "Employee Date Range Dialog", , , , , acDialog
' Cancel Report if User Clicked the Cancel Button
If IsLoaded("Employee Date Range Dialog") = False Then Cancel = True
' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub
FOR THE REPORT (OnClose):
Option Compare Database
Private Sub Report_Close()
DoCmd.Close acForm, "Employee Date Range Dialog"
End Sub
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 Sales By Category Dialog
DoCmd.OpenForm "Employee Date Range Dialog", , , , , acDialog
' Cancel Report if User Clicked the Cancel Button
If IsLoaded("Employee Date Range Dialog") = False Then Cancel = True
' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub
FOR THE MODULE:
Option Compare Database
Option Explicit
Public bInReportOpenEvent As Boolean ' Is report in the Open event?
Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or
' Datasheet view.
Dim oAccessObject As AccessObject
Set oAccessObject = CurrentProject.AllForms(strFormName)
If oAccessObject.IsLoaded Then
If oAccessObject.CurrentView <> acCurViewDesign Then
IsLoaded = True
End If
End If
End Function
Please let me know if you need any additional information.
Thanks in advance...
1. Employee name
2. start date
3. end date
I entered the code according to the microsoft access online website
(http://office.microsoft.com/en-us/access/HA011170771033.aspx?pid=CH063653181033)
I can run the report and the dialog box will come up, but the 'OK' and
'cancel' buttons don't work. It's just frozen.
Since I know you will be asking for the VBA coding here it is...I put the
name for each code in CAPS...
FOR THE FORM (OnOpen):
Option Compare Database
Private Sub Cancel_Click()
DoCmd.Close
End Sub
Private Sub Form_Open(Cancel As Integer)
If Not bInReportOpenEvent Then
' If we're not called from the report
MsgBox "For use from the Evals by Employee Name (date range) Report
only", _
vbOKOnly
Cancel = True
End If
Form_Open_Exit:
Exit Sub
End Sub
Private Sub OK_Click()
Me.Visible = False
End Sub
FOR THE REPORT (OnOpen):
Option Compare Database
Private Sub Report_Close()
DoCmd.Close acForm, "Employee Date Range Dialog"
End Sub
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 Sales By Category Dialog
DoCmd.OpenForm "Employee Date Range Dialog", , , , , acDialog
' Cancel Report if User Clicked the Cancel Button
If IsLoaded("Employee Date Range Dialog") = False Then Cancel = True
' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub
FOR THE REPORT (OnClose):
Option Compare Database
Private Sub Report_Close()
DoCmd.Close acForm, "Employee Date Range Dialog"
End Sub
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 Sales By Category Dialog
DoCmd.OpenForm "Employee Date Range Dialog", , , , , acDialog
' Cancel Report if User Clicked the Cancel Button
If IsLoaded("Employee Date Range Dialog") = False Then Cancel = True
' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub
FOR THE MODULE:
Option Compare Database
Option Explicit
Public bInReportOpenEvent As Boolean ' Is report in the Open event?
Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or
' Datasheet view.
Dim oAccessObject As AccessObject
Set oAccessObject = CurrentProject.AllForms(strFormName)
If oAccessObject.IsLoaded Then
If oAccessObject.CurrentView <> acCurViewDesign Then
IsLoaded = True
End If
End If
End Function
Please let me know if you need any additional information.
Thanks in advance...