Cascading combo box add text

  • Thread starter Thread starter matt donker via AccessMonster.com
  • Start date Start date
M

matt donker via AccessMonster.com

Okay here is my thing have cascading combo boxes and the code for one of
them looks like this:

Dim str As String


If Forms![frmSelect]![lbPart#] = "ALL" Then
str = "SELECT DISTINCT [Fixture #] FROM [tblFixtures]"
Else
str = "SELECT DISTINCT [Fixture #] FROM [tblFixtures] WHERE [Part Used For]
= Forms![frmSelect]![lbPart#]" & ", ALL"
End If

Forms![frmSelect]![lbFixture#].RowSource = str

Now what i want to do in the else statement is have that query run get all
of the right records and then add a record at the end that just says "ALL".
As you can see if the user selects all then all records would be displayed.

So i guess my question is : Is it possible to add a single record of what
you want on in automation code after running a query to place the proper
records in???

Thanks in advance to anyone who helps and sorry if this is something that
you guys answer all the time but i couldn't find it.
 
Hi,



Inefficient, but it may work:

str="SELECT [fixture #] FROM Fixtures WHERE [Part Used For]=
Forms![frmSelect]![lbPart#]
UNION
SELECT 'ALL' FROM Fixtures "


The DISTINCT is not required anymore, since UNION does it for you.


It is inefficient because SELECT 'ALL' FROM Fixtures generates m
records, all identical, with the word 'All', and the UNION removes m-1 of
them.


Hoping it may help,
Vanderghast, Access MVP
 
Back
Top