473,394 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Help with query criteria

I have a database that produces different "cuts" of data for the user
to export into excel. The database essentially opens queries using
different criteria to filter the data as the user wants it. The user
can then print or export to excel depending on the need.

So I have a form that allows the user to specify how the data should
be cut. I'm stumped on one aspect of this. I have a field called
"Category" that has 10 possible values. None of the records have a
null value for this field. I would like to have a checkbox (or another
type of control) on my form that a user can check off. When the box is
checked, the query will open and exclude any records that have one of
5 values for that field. Any records with a value other than one of
those five would be displayed. Essentially, I am trying to exclude
temporary and per diem employees from the query (if the user wants
them excluded), and the category value for temps & per diems can be
any of 5 values. So it's not straightforward to exclude them.

I'm not a sophisticated programmer. So any simple approaches would be
appreciated. I had thought of setting up separate queries (so a
different query opens if the box is checked), but I need to repeat
this process on a few other queries, and this would be a cumbersome
approach.

Another thought (just occuring to me now) is to create new "field" in
the query (using code) that determines which employees are temps/per
diems with a case statement and returns a single uniform value for any
temps/per diems. And then, if the box is checked, send one value to
the criteria line of that new "field" to exclude them. Would that
work?

Thanks.
Jun 27 '08 #1
1 1414
I don't know if you've done any queries in VBA code but I think that would
be the easy way.

Something like this air code:

strSQL = "Select * from tblPersonnel;"
'Thats your basic query - then you test for the checkbox
If Me.chkNoTemps then
strSQL = Left(strSQL ,len(strSQL)-1) ' this gets rid of the original
semi colon
' This adds the WHERE clause
strSQL = strSQL & " WHERE JobType NOT IN ('Temp', 'PerDiem', 'type3',
'type4','type5) ;"
End If

DoCmd.RunSQL(strSQL)

' If the checkbox isn't checked you get everything. If it is you get
everthing but the temps et al.

Regards

Kevin
"Coll" <co*********@hotmail.comwrote in message
news:e4**********************************@p25g2000 hsf.googlegroups.com...
>I have a database that produces different "cuts" of data for the user
to export into excel. The database essentially opens queries using
different criteria to filter the data as the user wants it. The user
can then print or export to excel depending on the need.

So I have a form that allows the user to specify how the data should
be cut. I'm stumped on one aspect of this. I have a field called
"Category" that has 10 possible values. None of the records have a
null value for this field. I would like to have a checkbox (or another
type of control) on my form that a user can check off. When the box is
checked, the query will open and exclude any records that have one of
5 values for that field. Any records with a value other than one of
those five would be displayed. Essentially, I am trying to exclude
temporary and per diem employees from the query (if the user wants
them excluded), and the category value for temps & per diems can be
any of 5 values. So it's not straightforward to exclude them.

I'm not a sophisticated programmer. So any simple approaches would be
appreciated. I had thought of setting up separate queries (so a
different query opens if the box is checked), but I need to repeat
this process on a few other queries, and this would be a cumbersome
approach.

Another thought (just occuring to me now) is to create new "field" in
the query (using code) that determines which employees are temps/per
diems with a case statement and returns a single uniform value for any
temps/per diems. And then, if the box is checked, send one value to
the criteria line of that new "field" to exclude them. Would that
work?

Thanks.

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Norma | last post by:
I am trying to make a query pull data from between the dates I enter in the parameter but also look back 'in time' to see where 2 other fields have null values, and only pull data into the query if...
5
by: Steve Patrick | last post by:
Hi All You guys are my last hope, despite spending money on books and hours reading them I still can not achieve the results I need. I have designed a database in Access 2000 based on 1 table,...
3
by: MLH | last post by:
Am repeating question with different subject heading, perhaps stating more clearly my problem... I have an A97 query (qryVehiclesNowners2) that has a table field in it named . Depending on the...
10
by: motessa | last post by:
Hello All, I am new to Access and have been looking for answers to my problem on the internet and have not found it yet. I hope someone can give me a hint. Thanks so much. I have a form...
7
by: Aaron | last post by:
Complete code follows. I am new to .NET programming (and programming in general) and I am having a difficult time understanding how to fill a variable in one sub, and then access it from...
4
by: DeanL | last post by:
Hi Guys, I need some help creating a query that is going to take between 1 and 10 parameters. The parameters are entered on a form into text boxes that may have data or be empty. Is there a...
3
by: mcmahonb | last post by:
Hey people... I've been searching this forum for a few hours and even though this topic has been went over from many different angles; I cannot seem to figure out how to make things work on my...
2
by: Haas C | last post by:
Hey all, I created a Query (in Design View) which asks the user for an "As Of Date" which would then display relevant data. I put in the Criteria Row of the Query Design for the Date field. Is...
47
by: Jo | last post by:
Hi there, I'm Jo and it's the first time I've posted here. I'm in process of creating a database at work and have come a little unstuck.....I'm a bit of a novice and wondered if anyone could...
1
by: kccoolrocks1981 | last post by:
I have two tables naming 1.) Criteria and 2.) IndicatorData. Criteria table has (CriteriaID, CriteriaName,CriteriaValues) Fields. Example( CriteriaName-'Gender 'and values would be 'Male'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.