Filter based on dates & checkbox

mba_110

Board Regular
Joined
Nov 28, 2012
Messages
80
Office Version
  1. 365
Platform
  1. Windows
Dear All,

Please I need your help in doing some extensions and filters to my form and report (rptRecruitments).

I have following fields in form

frmCombinedReports
txtFromDate
txtToDate
BtnReportView
ChkAllRecords

I have already filter the form dates with report query to show records only as per the date selected on form (txtFromDate & txtToDate) however, I need when I select the check box (chkAllRecords) for the frmCombinedReports then (txtFromDate & txtToDate) should be automatically blank because I am selecting entire records in report and not based on dates, but since I have already mentioned the between criteria in report query to filter it as per the form dates I am unable to work out with both ways as per period and as per all record check function.

Any help here will be much appreciated.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Its look little complicated as i have already my code working with report button

Code:
Private Sub BtnPriptPreview_Click()    Dim sReportName     As String
    Dim sReportPath     As String
    Dim Filename        As String


If IsNull(Me.cboCatagory) Or IsNull(Me.cboReportName) Then
        MsgBox "Please select all required fields marked with * to proceed further for preview. !"
Exit Sub
End If


        
    sReportName = Me.cboReportName.Column(2)


    DoCmd.OpenReport sReportName, acViewPreview


    Exit Sub




End Sub

If you can suggest the easiest way or advise how to amend the above code to include these functions.
 
Upvote 0
Not really.
You use the Openargs parameter to determine if you need to filter on date or vice versa.
You change the record source on the open event of the report.
I probably would not do it exactly that way as they are passing in the sql string as the openarg parameter.

I'd code the two sql strings in the report open event and then choose which one to use with the openargs parameter.
So it is just two swql strings, an if test and add a new parameter.
That parameter is the last one in the DoCmd.OpenReport command

If the criteria is not too complicated, you could use the where clause as instead.
https://msdn.microsoft.com/en-us/library/office/ff192676.aspx

HTH
 
Upvote 0

Forum statistics

Threads
1,221,692
Messages
6,161,351
Members
451,697
Latest member
pedroDH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top