Hi, I am having some trouble. I am using a select case with option groups on a form. The first option group (grpReportType) on the form passes a variable to the button on the form (cmdOpenReport - onclick), to choose what report to open.
In the report open code , I am trying this Case Select code to look at the second option group on the form (grpReportDate). This should tell the report what date option to choose.
1 is today (me.reportdatefield = Date)
2 is choose a date (form date field)
3 is date range, and
4 is all.
It is 3, the date range, that I cannot seem to get right.
Here is my latest attempt:
The most common error I get is:
" Compile Error
Expected: Line or number or label or statement or end of statement"
Here are some of the other statements that I have tried for Case 3. None of them have worked either.
At least I can say that I am trying. At most I can say that I cannot seem to solve this and I would really like to.
Any help is appreciated!
Thanks
misscrf
It is never too late to become what you could have been ~ George Eliot
In the report open code , I am trying this Case Select code to look at the second option group on the form (grpReportDate). This should tell the report what date option to choose.
1 is today (me.reportdatefield = Date)
2 is choose a date (form date field)
3 is date range, and
4 is all.
It is 3, the date range, that I cannot seem to get right.
Here is my latest attempt:
Code:
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_Report_Open
Dim MyFromChoose As Date
Dim MyTo As Date
MyFromChoose = [Forms]![frmReports]![txtFromChoose]
MyTo = [Forms]![frmReports]![txtTo]
Select Case Forms![frmReports]![GrpReportDate]
Case 1
Me.ActivityDate = Date
Case 2
Me.ActivityDate = MyFromChoose
Case 3
Me.ActivityDate Between(MyFromChoose And MyTo)
Case 4
Me.ActivityDate = "*"
End Select
Exit_Report_Open:
Exit Sub
Err_Report_Open:
MsgBox Err.Description
Resume Exit_Report_Open
End Sub
The most common error I get is:
" Compile Error
Expected: Line or number or label or statement or end of statement"
Here are some of the other statements that I have tried for Case 3. None of them have worked either.
Code:
Me.ActivityDate >= Format(Forms![frmReports]![txtFromChoose], "mm/dd/yyyy") And <= Format(Forms![frmReports]![txtTo], "mm/dd/yyyy")
-------------
Me.ActivityDate & " Between " & Format(Forms![frmReports]![txtFromChoose], "\#mm\/dd\/yyyy\#") _
& " And " & Format(Format(Forms![frmReports]![txtTo], "\#mm\/dd\/yyyy\#")
----------------------
"Me.ActivityDate Between #" & Format(Forms![frmReports]![txtFromChoose],"mm/dd/yyyy") & "# And #" & Format(Forms![frmReports]![txtTo],"mm/dd/yyyy") & "#"
------------------
((Me.ActivityDate) between DateValue('" &
Forms![frmReports]![txtFromChoose] & "') AND DateValue('" &
Forms![frmReports]![txtTo] & "'));"
----------------
"Me.ActivityDate >=#" & Forms![frmReports]![txtFromChoose] & "# AND Me.ActivityDate <= #" & Forms![frmReports]![txtTo]
& "#"
--------------------------
"Me.ActivityDate >= #" & Forms![frmReports]![txtFromChoose] & "# AND Me.ActivityDate <= #" & Forms![frmReports]![txtTo] & "#"
--------------------
Me.ActivityDate Between & Format(Forms![frmReports]![txtFromChoose], "mm/dd/yyyy") & "# And #" & Format(Forms![frmReports]![txtTo], "mm/dd/yyyy") & "#"
--------------------
((tblActivities.ActivityDate) Between [Forms]![frmReports]![txtFromChoose] And [Forms]![frmReports]![txtTo])
At least I can say that I am trying. At most I can say that I cannot seem to solve this and I would really like to.
Any help is appreciated!
Thanks
misscrf
It is never too late to become what you could have been ~ George Eliot