472,353 Members | 2,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Show all records through combo box and command button

This seems simple enough, but I am having problems.
I have a table of customer information. I have a form with various combo boxes displaying unique customer information (in this case, zone and broker, but I'll add others before it is done.
I want each user to choose what they want out of the combo boxes, then hit the command button, which will display the results on a customized form. If they choose both combo boxes, it works gerat.
The problem I am having that if the user just chooses zone, but nothing in broker, it display no results. I thought adding an " All" to each would cure that, but it has not, but I don't think I am doing it correctly.

I'll show exactly what I have so far. For the Broker Combo Box I have as my row source:
Expand|Select|Wrap|Line Numbers
  1. SELECT BROKER As Filter, BROKER FROM CUSTOMERS UNION SELECT "*" As Filter ," All" As BROKER FROM CUSTOMERS ORDER BY BROKER;
My column count is 2, column width is 0", 2".

This brings an option in my combo box with the name All, but if you choose that and hit the command button, no results are displayed.

The code I have in the command button is:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command5_Click()
  2. DoCmd.OpenForm "ALLCUSTOMERSFORM", , , "[BROKER] = '" & Me![Combo1].Column(0) & "' AND [ZONE] = '" & Me![Combo2].Column(0) & "'"
  3.  
  4. End Sub
  5.  
Now I think my problem is that all I have done is add the All option to the combo box, but I need something else to tell it to actually show all.
Maybe something in the After Update section, but I don't know what!

Please help!!!

Thank you!
Mar 3 '08 #1
3 5318
Megalog
378 Expert 256MB
If you're only going to use "All" in ONE combo box, then this should work:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command5_Click()
  2. if me.combo2.value = "All" or isnull(me.combo2.value) then
  3.      DoCmd.OpenForm "ALLCUSTOMERSFORM", , , "[BROKER] <> '" & Me![Combo1].value & "' AND [ZONE] = '" & Me![Combo2].value & "'"
  4. else
  5.       DoCmd.OpenForm "ALLCUSTOMERSFORM", , , "[BROKER] = '" & Me![Combo1].value & "' AND [ZONE] = '" & Me![Combo2].value & "'"
  6. End Sub
So basically if the value is "All" or is nothing, then it will return any values that do not match "All" or nothing. Otherwise, it should filter off whatever broker is selected.
Mar 3 '08 #2
If you're only going to use "All" in ONE combo box, then this should work:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command5_Click()
  2. if me.combo2.value = "All" or isnull(me.combo2.value) then
  3.      DoCmd.OpenForm "ALLCUSTOMERSFORM", , , "[BROKER] <> '" & Me![Combo1].value & "' AND [ZONE] = '" & Me![Combo2].value & "'"
  4. else
  5.       DoCmd.OpenForm "ALLCUSTOMERSFORM", , , "[BROKER] = '" & Me![Combo1].value & "' AND [ZONE] = '" & Me![Combo2].value & "'"
  6. End Sub
So basically if the value is "All" or is nothing, then it will return any values that do not match "All" or nothing. Otherwise, it should filter off whatever broker is selected.
Thank you, but I would prefer if All were a part of each combo box.
For example: If someone just wanted to see all East customers, they would selecte East as Zone and All as broker.

Any suggestions?
Mar 3 '08 #3
JKing
1,206 Expert 1GB
Here's an article that you may wish to read. It's fairly well written and has links to examples you can download.

Adding "All" option to a combobox
Mar 3 '08 #4

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

Similar topics

6
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to...
2
by: Todd | last post by:
Hi. I want to sort the records on my form (using either a continuous form or a datasheet) by the unbound "description" column in a combo box on...
0
by: Jason | last post by:
I would like to be able to place a command button on a primary (parent) form that opens up a subform. I want to use this subform to search for or...
1
by: meganrobertson22 | last post by:
Hi Everyone- I am trying to use a simple macro to set the value of a combo box on a form, and I can't get it to work. I have a macro with 2...
2
by: Zeljko | last post by:
I'm creating Address book. Header of the main form (frmAddress) contains combo box (cboFilter) to filter records by Occupation on main...
4
by: virtualgreek | last post by:
Dear All, First of all I would like to take the time to thank you all for your efforts and time spent at this wonderful forum. I have found it...
2
by: altesse33 | last post by:
I have a command button on the main form of my database that allows users to add new records. But, even though new records get added to the sub table...
2
by: banderson | last post by:
Hello, I have a data entry form for a table with information about buildings and am having a problem making a combo box do what I want. I would like...
2
by: pteargryphon | last post by:
I'm a filry new user to Access and a novice when it comes to VBA. I have a form that contains two combo boxes. The first one is populated by a querry...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

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.