Filtering form by combobox, show ALL records if no selection made? (1 Viewer)

Denise2020

Member
Local time
Today, 09:01
Joined
Mar 31, 2020
Messages
82
Hello again wonderful people!

I have a form that contains a combobox which I use to filter records based on a field. There is a button which creates a report based on the "results" of that filter which makes a calculation of total time. I have two problems just now:

1) I want a time report for ALL records, thereby not filtering, but making no choice in the combobox results in a report which shows zero records.
2) I cannot figure out a way to put other filters on the form and generate the report. Just now, making a selection in the combobox selects ALL records with that selection. I would like to be able to pick all records from that selection, from a specific YEAR, without the user having to go into the query to modify it, as they are all unfamiliar with Access.

My (probably unsightly) implementation is currently this way:

a query to generate the report with the field condition of:
Like [Forms]![formname]![cboName]

a combobox on the form with the row source:
SELECT DISTINCT qryName.fieldname
FROM qryName
ORDER BY qryName.fieldname

and a button on the form with the after update event
Me.Filter = "[fieldname] = " & Chr(34) & Me.cboName & Chr(34)
Me.FilterOn = True

I hope this makes sense. Thanks in advance!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:01
Joined
Oct 29, 2018
Messages
21,358
Hi. Rather than using this:
Code:
Like [Forms]![formname]![cboName]
Try using this instead:
Code:
[Forms]![formname]![cboName] OR [Forms]![formname]![cboName] Is Null
Hope that helps...
 

Denise2020

Member
Local time
Today, 09:01
Joined
Mar 31, 2020
Messages
82
You are a lifesaver!! I had tried so many forms of OR (Like "*" for example) but nothing worked. Thank you so much!

Now if I can just filter it by Year and Officer...
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:01
Joined
Oct 29, 2018
Messages
21,358
You are a lifesaver!! I had tried so many forms of OR (Like "*" for example) but nothing worked. Thank you so much!

Now if I can just filter it by Year and Officer...
Hi. You're welcome. There are plenty of demoes on how to filter a form. Try searching for "search forms."
 

Users who are viewing this thread

Top Bottom