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
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
700
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
700
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,767
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.
 

Forum statistics

Threads
1,082,167
Messages
5,363,532
Members
400,747
Latest member
monty_gl

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top