Combo box

billmark

Board Regular
Joined
Dec 11, 2011
Messages
59
Hi
I created a combo box in the form to select the record and export to excel (I created a button). Please advise how to make the combo box with one blank at the top of the list so that I select the blank, then all record can be exported to excel.

Regards
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Paul Ked

Active Member
Joined
Jun 4, 2015
Messages
442
Why blank? Why not make your 1st item in the combo "Select All" and act on that?
 

billmark

Board Regular
Joined
Dec 11, 2011
Messages
59
I tried this in the Row Source 'Select clt.Field1 FROM Client UNION Select "(All)" FROM Client GROUP BY clt.Field1'. When I select ALL from the combo box, it gives me blank.
Please advise how to fix.
 

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
885

ADVERTISEMENT

I tend to use a union and 0 for All. Then test for 0. If 0, select everything, if not build the criteria then select
 

billmark

Board Regular
Joined
Dec 11, 2011
Messages
59
I tried this
Select “ALL” FROM Client UNION Select clt.Field1 FROM Client GROUP BY clt.Field1

and a prompt to ask me to Enter the parameter.

Please assist if I need to adjust in the properties table or advise the correct statement.

The table Client has 5 fields.
 

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
885

ADVERTISEMENT

Firstly, whilst you can have as many fields as you want in a combo, I try and stick with 2. The PK Autonumber and the field I want as the dexcription.

Code:
SELECT ID, Rank from Rank
UNION
Select 0 AS ID, "All" as Rank from Rank
Order by ID

Then check for non zero ID and filter/adjust accordingly.

HTH
 

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
2,089
Office Version
  1. 365
Platform
  1. Windows
cross posted
 

stumac

Active Member
Joined
Jul 16, 2010
Messages
471
I think based on the information on the other post, the issue you have is you want the combo box to say ALL but have the query checking for Null. change it to check for 'ALL':

VBA Code:
[forms]![main]![cbofield1] or [forms]![main]![cbofield1] = "ALL"

basically the second part of the expression evaluates to true if the combo box has ALL in it therefore returning all records.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,791
Messages
5,638,340
Members
417,021
Latest member
moon miner

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top