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
 

Paul Ked

Active Member
Joined
Jun 4, 2015
Messages
434
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
677
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
677
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
1,742
cross posted
 

stumac

Active Member
Joined
Jul 16, 2010
Messages
470
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.
 

Forum statistics

Threads
1,077,918
Messages
5,337,180
Members
399,131
Latest member
Vinnyjuice

Some videos you may like

This Week's Hot Topics

Top