473,795 Members | 2,968 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using a control on a form to determine criteria for a query

I have a form and a query. I would like to have some control on the
form (check box probably), that when selected will limit the criteria
for a field in a query. Here are the details....

When the checkbox (or whatever control is appropriate on the form) is
checked, the field "employment_cat egory" in my query will have the
following criteria - not "temp" and not "diem" - I've tried several
things, but I can't seem to figure out how to feed the criteria for
that field. Any suggestions?

Colleen
Jun 27 '08 #1
2 2115
"Coll" <co*********@ho tmail.comwrote in message
news:fc******** *************** ***********@f36 g2000hsa.google groups.com...
>I have a form and a query. I would like to have some control on the
form (check box probably), that when selected will limit the criteria
for a field in a query. Here are the details....

When the checkbox (or whatever control is appropriate on the form) is
checked, the field "employment_cat egory" in my query will have the
following criteria - not "temp" and not "diem" - I've tried several
things, but I can't seem to figure out how to feed the criteria for
that field. Any suggestions?
Your request is a little bit more difficult. If it was "just" ONE condition,
it would be quite easy.
You would simply place the form name + control name right into the query
builder in the condition area.

In your case, we have to solve a few problems.

If the check box is NOT checked, then I assume you do NOT want the
conditions (the report will ignore..or show all).

Checking "one" checkbox to do "two" conditions will require you to write
some code.

The idea would be build form with a heck box. (and, a button to "launch" the
report.

The code behind our button to launch the form would be:

dim strWhere as string

if me.MyCheckBox = true then
strWhere = "employment_cat egory <'not temp'" & _
" and employment_cate gory <'diem'"
end if

docmd.OpenRepor t "nameOfReport", acViewPreview,, strWhere

Note that the above will NOT include records where employment_cate gory is
blank.

In the above you have to replace "myCheckBox " with the name of your check
box.

The above is likely the approach I would use, but it does mean you have to
write a bit of code...

Here is some more screen shots which use the above idea for reports:

http://www.members.shaw.ca/AlbertKal.../ridesrpt.html
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl************* ****@msn.com
Jun 27 '08 #2
On Apr 19, 9:58*pm, "Albert D. Kallal" <PleaseNOOOsPAM mkal...@msn.com >
wrote:
"Coll" <col_mcma...@ho tmail.comwrote in message

news:fc******** *************** ***********@f36 g2000hsa.google groups.com...
I have a form and a query. I would like to have some control on the
form (check box probably), that when selected will limit the criteria
for a field in a query. Here are the details....
When the checkbox (or whatever control is appropriate on the form) is
checked, the field "employment_cat egory" in my query will have the
following criteria - *not "temp" and not "diem" - I've tried several
things, but I can't seem to figure out how to feed the criteria for
that field. Any suggestions?

Your request is a little bit more difficult. If it was "just" ONE condition,
it would be quite easy.
You would simply place the form name + control name right into the query
builder in the condition area.

In your case, we have to solve a few problems.

If the check box is NOT checked, then I assume you do NOT want the
conditions (the report will ignore..or show all).

Checking "one" checkbox to do "two" conditions will require you to write
some code.

The idea would be build form with a heck box. (and, a button to "launch" the
report.

The code behind our button to launch the form would be:

dim * strWhere * * * *as string

if me.MyCheckBox = true then
* *strWhere = "employment_cat egory <'not temp'" & _
* * * * * * * " and employment_cate gory <'diem'"
end if

docmd.OpenRepor t "nameOfReport", acViewPreview,, strWhere

Note that the above will NOT include records where employment_cate gory is
blank.

In the above you have to replace "myCheckBox " with the name of your check
box.

The above is likely the approach I would use, but it does mean you have to
write a bit of code...

Here is some more screen shots which use the above idea for reports:

http://www.members.shaw.ca/AlbertKal.../ridesrpt.html

--
Albert D. Kallal * *(Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKa l...@msn.com
Thank you. One more question - just to complicate things a bit further
- if the box is checked, there are 4 possible field values that I
would want to exclude. Three of them include the word *temp* - can I
use your code with the wildcards or do I need to spell out each of
those 3 values. Also, I am opening a query rather than a report - it's
a data dump for users to then export to Excel - I'm assuming that
wouldn't cause any problems,and the code will still work with
docmd.openquery ...?
Jun 27 '08 #3

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

Similar topics

6
2137
by: CFW | last post by:
References in Access and .mdb files have always been painful for me - just when I thought I was OK in an .mdb, I have a .adp I'm working on and I need to use Set db as CurrentDb - Constant "object variable or with block variable not set" error almost killed me and VB Help says "If you want to use the CurrentDb method in an Access project (.adp) you must set a permanent reference to the DAO 3.6 Object library in the Microsoft Visual Basic...
6
1953
by: Megan | last post by:
Hi everybody- I'm trying to use a checkbox to control whether or not a date field in a query "Is Null" or "Is Not Null." I have 2 date fields: InDate and OutDate. If there is an OutDate, then the record is finished. If there is no OutDate, then the record is not finished. I'm using an unbound form (frmStatus) to enter data into a query to
12
6392
by: Steve Elliott | last post by:
I have a query set up to gather together data between two specified dates. Shown in the query column as: Between #24/09/2004# And #01/10/2004# Is it possible to enter several different date ranges, ie between 24/09/2004 and 01/10/2004 together with 05/10/2004 and 07/10/2004 ? If I enter the "Between" criteria on different lines it returns no data.
3
2758
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality (we're sales offices, and I'm doing things such as associate directories, commission calculations, order tracking, etc.). 2003 seems to have a few extra features, but I seem to continually run in to oddities that seem like they SHOULD work, but...
2
2470
by: ChasW | last post by:
I just read these 2 pages. These are most helpful, but leave me with a question. http://www.mvps.org/access/queries/qry0005.htm http://www.mvps.org/access/forms/frm0007.htm I have a Multi Select Listbox that will define query criteria for a query that is the record source for another form. Certain individual selections in this list box may act a label for a
10
2585
by: john | last post by:
I have a report to print envelopes. The report is based on a query. Now I need to make 10 more queries to make different selections of addresses. Every query has the same output fields as the already existing query. I know I can copy the report and base it on another query but then I would have to make 10 extra reports. How can I use just one report for all of the queries? At the moment I use the button wizard in my forms to make buttons...
3
1989
by: Bob Alston | last post by:
I have recently been trying to determine the best technique to pull the least amount of info across the LAN link in a slow speed LAN situation (e.g. < 10 Mbps), where data volume = performance. After much confusion from reading a lot of info, some of which had conflicting info, it appears that setting the record source of a form equal to a sql statement that has the selection criteria as part of the sql statement, rather than using a...
1
4286
by: tomlebold | last post by:
Having problems displaying query results from combo boxes on a sub form, which is on the same form that is used to select criteria. This has always worked form me when displaying query results on another main and sub form. The requery on the sub form and refresh comands on the main form do not work when the form is first displayed and when the selection criteria is changed. Should I be doing a refresh and then repaint of the sub form. ...
2
2142
by: JamesQ | last post by:
Hello there, I have a dropdown on a form which i use as a criteria for a query. However the field being searched contains many entries - it holds a list of subject choices - so when i pass a value using forms!! it only returns those records that have that exact match. For example, Field = Subject, values are Computers, Photography, Maths. My control/drop down if i select Maths, returns only those records that have Maths on its own. When i...
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10439
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7541
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.