473,441 Members | 1,965 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,441 software developers and data experts.

Using a Check Box to pass a value to a query

I have a question which I'm sure has a simple answer, but I'm pretty new at this.

I have a database which contains several tables including tblModules and tblParts. tblParts stores module numbers attached to part numbers, using the combination of module number and part number as the primary key. The tblModules table has module numbers/location/description.

I have a form which allows the user to input part numbers, which runs a query which results in showing only modules which contain the parts. I would like to create a check box that will include a part number (prt913004) in the query when checked, but will return only modules that do NOT contain the part when unchecked.

Any idea how to do this? All help is appreciated. Thanks!
Aug 31 '07 #1
2 1529
cyberdwarf
218 Expert 100+
Hi Nick

Try something like this for the AfterUpdate event of the Part number field:-
Expand|Select|Wrap|Line Numbers
  1. If Me.Chackbox=False Then
  2.     Me.Comboname.ControlSource="SELECT * from tblModules Where PartNumber=" & Me.PartNumber
  3. Else
  4.     Me.Comboname.ControlSource="SELECT * from tblModules Where PartNumber<>" & Me.PartNumber
  5. EndIf
  6. Me.Comboname.Requery
HTH
Steve
Aug 31 '07 #2
Thanks for the prompt reply Steve!

I like how that code is structured, and its very close to what I was hoping for, however, is there a way to output to a query rather than to a combo box? I have many filters for different parts and descriptions and so on, all of which go to a master query which populates a list box in my form. Can I have the IF statement fill in the criteria in a query?

Thanks again.
Aug 31 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: phpuser32423 | last post by:
Hi everyone Is it by any chance possible to use mysql and php to auto create the content for drop-down lists on forms by retrieving the values from a database? The reason i ask is that on a site...
3
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are...
4
by: Oceania | last post by:
Hi All, I did try using the sample code from the ADO.net forum to link one table, it is working fine. But, I got a problem when I tried to link all tables (20 tables)... Please help, thank...
2
by: Randy | last post by:
I am trying to relink some Oracle tables in an Access database via VB.NET and ADOX. I receive the following error when executing the cat.ActiveConnection link "Arguments are of the wrong type,...
1
by: Anonieko | last post by:
Understanding and Using Exceptions (this is a really long post...only read it if you (a) don't know what try/catch is OR (b) actually write catch(Exception ex) or catch{ }) The first thing I...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
5
by: Andrew Meador | last post by:
I have a form (Change Card List by Status) with a check box (cboNOT) and a list box (lstStatus). There is an Open Report button that opens a report (Report - Change Card List) which uses a query...
82
by: happyse27 | last post by:
Hi All, I modified the user registration script, but not sure how to make it check for each variable in terms of preventing junk registration and invalid characters? Two codes below : a)...
2
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
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
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,...
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,...
1
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...
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...
0
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,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.