when you're in the Design view of a query (not the SQL pane), the correct
entry on the Criteria line for a Yes/No data type field is simply True or
False, without any quotes. however, to refer to a control on a form to get
the criteria value (rather than "hard-coding" a specific value into the
query), use a form reference on the criteria line, as
Forms!FormName!CheckboxControlName
replace FormName with the actual name of the form, and CheckboxControlName
with the actual name of the checkbox control, of course.
in your query, you'll need a reference for each checkbox field. the trick
here is to set up the criteria as OR references, not AND references. to do
this, put the reference criteria on the first Criteria line of the first day
field. then move over to the next day field, and put the reference criteria
on the second Criteria line - leaving the first line blank. then move over
to the next day field, and put the reference criteria on the thrid Criteria
line - leaving the first and second lines blank. continue in this fashion,
"stair-stepping" the reference criteria, until you've added criteria for
each day field that refers to the corresponding "day" checkbox on the form.
next, add the following code to the Click event procedure of the command
button on the form, as
DoCmd.OpenQuery "NameOfQuery"
With Me
!chkMon = Null
!chkTues = Null
!chkWed = Null
!chkThurs = Null
!chkFri = Null
!chkSat = Null
!chkSun = Null
End With
substitute the correct name of the query and the correct names of the
checkbox controls on the form, of course. the above code opens the query,
obviously; if you want to open a form or report that's bound to the query
(usually preferable to opening a query directly), then change the Open
command accordingly.
hth
Tom said:
Wayne,
Here goes.
Access 2000
Database "AbleDispatch.mdb"
Objects
Queries
"ScheduledRunsQuery"
Based on Table "ScheduledRuns"
Design View
Field: Sunday Monday
Tuesday etc.
Criteria: "WHERE [ScheduledRuns].[Monday]"=True
That was placed under Monday criteria
I tried just typing an "=yes" under Monday and that
worked. However - this is for other users. I don't
want them into the file system for this. Is there
a way for them to input, after pressing a command
button, the day of the week? If I put and Input statement
under each day, then obviously it would bring up
7 screens to input. I would think that if you entered
a "yes" or "no" under just the day needed, leaving
all others blank, then it would return just that day.
Hope that helps
Tom
Wayne Morgan said:
If that's the entire SQL then where are you using it? That is only the WHERE
clause to a query, not the entire query. Please post what you are using and
where you're using it.
--
Wayne Morgan
MS Access MVP
Tom said:
This is it
"WHERE [ScheduledRuns].[Monday]"=True
I tried taking out the "" but it would not let me
Running Access 2000
Tom
:
Please post the entire SQL of the query, I suspect the problem is that
the
quotes shouldn't be there.
--
Wayne Morgan
MS Access MVP
Wayne,
I tried this in Criteria, and it did not work
it returned every record
"WHERE [ScheduledRuns].[Monday]"=True
Tom