473,395 Members | 2,443 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,395 software developers and data experts.

Optional criteria in query

2
I have a form with 2 comboboxes (dept, section) and a listbox (employees).
Listbox is based on a query with 2 criteria (Forms!Form!Dept and Forms!Form!Section). Whenever I choose values in both comboboxes listbox works fine. But how can I make section criteria optional i.e. when choosing dept I would see all the dept's employees, and when I need to choose section the list would get shrinked to just the section's employees.
I've tried (according to MSKB) Forms!Form!Section Or Forms!Form!Section Is Null - but when I save the query Forms!Form!Section Is Null disapperars...
Am I doing something wrong? I'm working on Acc2000 - any suggestions?
Jun 30 '06 #1
1 3162
zzqxxq
28
Here's how I would handle it

I would make a new query based only on the department combo box - then when a user selects a department all the employees in that department would fill the listbox - just like you want to do

then use the original query with the section box so that if a user selected a section AFTER selecting department he would get the list box of just that sections' employees - like you get now.

To prevent the section combo box from being selected first, do a little test using the onchange function -

sub SectionComboBox_OnChange

If Len([ListBoxName]) < 1 then
MsgBox "You must select a department before selecting a section", vbOkOnly
SectionComboBox.Value = 0
Else
DoCmd.OpenQuery "Your Query Name Here"
Endif

End Sub

if the list box is empty and the user tries to change the section combo box -it display a message box saying you must select a department first - with an ok button then sets the section button back to no selection (0) - otherwise it does the section query (the one you have now) using the selected department and section.

Write if you need more help
Jul 13 '06 #2

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

Similar topics

6
by: AAVF | last post by:
Hi We have a problem with a query. An Access database links via ODBC to a UNIX server. To speed things, we use the ODBC to load the relevant tables to the local PC that runs Access so that...
2
by: Matthew | last post by:
Hey , I have built a query which takes values from unbounded fields on a form, and it all works except for one thing. I have a few fields in my query that are dates. I also have a start and...
0
by: MLH | last post by:
I have an A97 query (qryVehiclesNowners2) that has a table field in it named . Depending on the selections made in a number of criteria choices on a form, a field on the form will have string...
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...
4
by: meganrobertson22 | last post by:
Hi Everyone- I have a question about how to add and then use the "All" selection in a combo box. I am trying to figure out how to: (1) add "All" as a selection to a combo box and then (2)...
21
by: Marc DVer | last post by:
I am trying to create a query that can be loaded as a querydef object but not having to assign values to the parameters if I don't want to. Normally when using a parameter query in VBA my code...
1
by: Woodies_46 | last post by:
Hello all, I've just hit a brick wall. What I have is a form with a heap of tick boxs and text box on it and down the bottom a subform with shows the results. i also have a search button down...
17
by: sharsy | last post by:
Hello guys, I would like some help in generating query criteria that will identify credit cards that have expired on an access database. The specific Field is formatted with a Data Type of...
1
by: jeannin | last post by:
I have a table with the following text fields Status group_type query_hits PLATFORM Group_No_7 Group_No_3 I need to be able have a form which uses combo boxes as required and optional...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.