I found a post with some code I thought would work for my needs but I don't know how to use it exactly.
The post (with the code) can be seen here:
Best way to prompt for report parameters in microsoft access
I have the form for the date inputs set up, I have the reports OnOpen using [Event Procedure] and the code pasted in there. When I generate the report, the pop up form is triggered but once I enter the dates it doesn't do anything. The original post doesn't go into details about the use of the code so I thought I'd ask here.
Here are the two code snippets:
AND:
I'm sure I have to change MyTable to my actual table [Calls] and DateField to my field name [Resolved Date] but then what?
Thanks,
Terry
The post (with the code) can be seen here:
Best way to prompt for report parameters in microsoft access
I have the form for the date inputs set up, I have the reports OnOpen using [Event Procedure] and the code pasted in there. When I generate the report, the pop up form is triggered but once I enter the dates it doesn't do anything. The original post doesn't go into details about the use of the code so I thought I'd ask here.
Here are the two code snippets:
Code:
Private Sub Report_Open(Cancel As Integer)
Dim dteStart as Date
Dim dteEnd As Date
DoCmd.OpenForm "dlgGetDates", , , , , acDialog
If IsLoaded("dlgGetDates") Then
With Forms!dlgGetDates
dteStart = !StartDate
dteEnd = !EndDate
End With
Me.Recordsource = "SELECT * FROM MyTable WHERE DateField Between #" _
& dteStart & "# AND #" & dteEnd & "#;"
DoCmd.Close acForm, "dlgGetDates"
End If
End Sub
Code:
Function IsLoaded(ByVal strFormName As String) As Boolean
' 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,
Terry
Comment