Form with checkbox

gsandy

Registered User.
Local time
Today, 18:17
Joined
May 4, 2014
Messages
104
I have an "on the fly" query within a form that has a checkbox (ckReWork) and a table (tblHourEnter) with a Yes/No field. When the query is run with the checkbox un-ticked I get results of all line items in table except those that are ticked. And when ticked get results of all ticked items. All as expected.
When the checkbox is un-ticked I would like a result that includes all ticked and un-ticked items. How do I modify the code (only part of the code is given) below to do this? Thanks Sandy

Code:
  If Not IsNull(Me.ckReWork.Value) = True Then
              strSQL = strSQL & " AND tblHourEnter.ReWork=" & Me.ckReWork.Value & " "
  End If
 
Merely remove the checkbox from the SQL string.
 
Thanks for that, but this is all new to me and I am on a steep learning curve!
How do I do what you suggest? Remember I would like one result that includes all ticked and un-ticked items and the other to include only ticked items. Thanks Sandy
 
If Not IsNull(Me.ckReWork.Value) = True Then
strSQL = strSQL & " AND tblHourEnter.ReWork=" & Me.ckReWork.Value & " "
End If

Remove or branch around the above code, i.e. the strSQL is not needed to display all values.
 
Still puzzled! I have 3 sets of code similar to above, one with job numbers, one with staff, one with date range and the one above. The final bit of code to bring it all together is as follows:

Code:
strSQL = strSQL & " ORDER BY tblHourEnter.JobNumber;"
    qdf.SQL = strSQL
    DoCmd.OpenQuery "JobSummaryQuery"
So I think I have to work with code original submitted and maybe put an "Else" into the "IF" to get what I want?
 
You're optionally building a SQL sting. I think you finally understand.
 
Well I don't know about that! I don't know what to enter after the Else to get it working as desired?
 
Another alternative, or End If, i.e.

If blah blah blah then
do somethinfg
Elseif blee blee blee than
do something else
Elseif waka waka waka
do whatever
Else
last chance tyo do somethng
end if
 
Thanks for your help, I will persevere with the ElseIf and get it working. Cheers Sandy
 

Users who are viewing this thread

Back
Top Bottom