By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,284 Members | 1,697 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,284 IT Pros & Developers. It's quick & easy.

Using a Check Box to pass a value to a query

P: 62
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
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 218
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

P: 62
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

Post your reply

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