Combo box Union query from empty table?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have unbound combo box with the following SQL:

SELECT tblClassNumberDropdown.CLASSID,
tblClassNumberDropdown.ActivityClassID, tblClassNumberDropdown.ClassNumber
FROM tblClassNumberDropdown UNION SELECT 0,"", "N/A" AS Expr1 FROM
tblClassNumberDropdown ORDER BY tblClassNumberDropdown.ClassNumber;

If I have no records in the table then how do I get the "N/A" to appear in
the combo box during drop down? Once an item is added during NotInList
procedure then the N/A appears. The reason I am asking is this DB is to be
sent out and I don't want to have to explain to everyone that they have to
populate a table before the N/A appears it just doesn't make sense. I also
have this type of procedure for a few other combo boxes. Is there a work
around for this? I thought a union was to join tables/queries together if
nothing is one shouldn't it still bring in the other? Thanks
 
Check for no records in the table (via a dcount?) and then set the SQL
accordingly.
 
You can use any other table in your database that you know it always
contains data to do the union with - no matter what the fields names are in
that table. Or create a work table with at least one record - some stuff
like application version or whatever... then this would work:

SELECT tblClassNumberDropdown.CLASSID,
tblClassNumberDropdown.ActivityClassID, tblClassNumberDropdown.ClassNumber
FROM tblClassNumberDropdown UNION SELECT 0,"", "N/A" AS Expr1 FROM
tblMyDummyTable ORDER BY tblClassNumberDropdown.ClassNumber;

Mike S.
 
Back
Top