Senin, 13 Juli 2015

RE: [MS_AccessPros] Filtering report with mulitple criterias

 

Art,
 
You would need to provide the logic of how you are using the check boxes. Your statement "filter by community, move-in date, city, class, project, tenant, unit number" doesn't suggest any column/field that would be a Y/N type.
 
Generically if you had a check box on the form chkEmpActive and a Y/N field EmpActive you could use
 
strWhere = strWhere & " AND [EmpActive] = " & Me.chkEmpActive
 
The problem with check boxes is they are yes/-1 or no/0. This makes it difficult to query all employees.
 
Again, it all depends on what you have for check boxes and how you want to filter your results.
 
Duane Hookom, MVP
MS Access

 

To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Mon, 13 Jul 2015 20:07:58 +0000
Subject: Re: [MS_AccessPros] Filtering report with mulitple criterias



How would I handle check boxes on my filter form. 

With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Anyone who claimed that old age had brought them patience was either lying or senile."  






From: "Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>
To: Access Professionals Yahoo Group <ms_access_professionals@yahoogroups.com>
Sent: Monday, July 13, 2015 3:02 PM
Subject: RE: [MS_AccessPros] Filtering report with mulitple criterias

 
Hi Art,
 
Good question.
 
I almost always leave the report's record source clear of any dynamic filtering. Assuming you have a form with a number of text and combo boxes and a button to open the report. The code to open the report might look like:
 
Dim strWhere as String
Dim strReport as String
strReport = "rptMyReportNameHere"
strWhere = "1= 1 "    'no effect on the filter
If Not IsNull(Me.txtStartDate) Then
    strWhere = strWhere & " AND [MyDateField] >= #" & Me.txtStartDate & "# "
End If
If Not IsNull(Me.txtEndDate) Then
    strWhere = strWhere & " AND [MyDateField] <= #" & Me.txtEndDate & "# "
End If
If Not IsNull(Me.txtCity) Then
    strWhere = strWhere & " AND [MyCityField] = """ & Me.txtCity & """ "
End If
If Not IsNull(Me.txtUnitNumber) Then
     strWhere = strWhere & " AND [MyUnitNumberField] = """ & Me.txtUnitNumber & """ "
End If
If Not IsNull(Me.txtSomeNumeric) Then
     strWhere = strWhere & " AND [MySomeNumericField] = " & Me.txtSomeNumeric & " "
End If
' add more criteria as needed watching for date, string, and numeric data types
DoCmd.OpenReport strReport, acViewPreview, , strWhere
 
Duane Hookom, MVP
MS Access

 
 

To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Mon, 13 Jul 2015 12:31:56 -0700
Subject: [MS_AccessPros] Filtering report with mulitple criterias




I am looking for an example of how to filter a report using multiple dropdowns. I have a report which I need to filter by community, move-in date, city, class, project, tenant, unit number. It could be single criteria or some or all of them. If anyone knows of anything, please let me know.


Thank you,


Art Lorenzini
Sioux Falls, SD






__._,_.___

Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (4)

.

__,_._,___

Tidak ada komentar:

Posting Komentar