jeudi 15 janvier 2015

Applying or removing a filter to an Access query field with a checkbox

I'm trying to apply a filter to a [Billed] column of a query, which is a yes/no field, by using a form.



HERE'S THE BACKSTORY:

I have a timesheet table (tblTimesheet) which contains information like [Date], [Job Number], [Employee], [Hours], [Billed], etc. When it's time to invoice for a specific job number, I generate a report for the job, then check the box in the [Billed] column for each record included in the invoice.



I queried tblTimesheet, then based frmJobTime on that query. I placed an unbound textbox on the form in order to filter the report (which is also based on the query). SO, the criteria under [Job Number] in the query looks like this:

[Forms]![frmJobTime]![txtJobNum]

It works PERFECTLY.



HERE'S THE ACTUAL PROBLEM:

I want to add a similar filter to the [Billed] column by adding a checkbox to frmJobTime. In a perfect world, checking the box would mean that the report only displays UNBILLED records for the job, and an unchecked box would mean that ALL records, both billed AND unbilled, appear in the report. I cannot get this to work.



I have Googled this a million different ways and have not come any closer to figuring out how to do this. I even changed my tactic to using a textbox (like I did for [Job Number]) so that you could filter for unchecked records by typing "False" on the form. That works, but if the textbox is left empty (which I thought meant that NO filter would be applied), no records at all appear in the report. I've also tried writing IIf() statements in the criteria, but I must be writing the formula incorrectly.



Is there a better way to go about doing this? Please help!! Replies in layman's terms would also be greatly appreciated.





Aucun commentaire:

Enregistrer un commentaire