views:

29

answers:

1

I have a combobox in Access 2003 whose recordset is obtained from a stored procedure. I need to find a way to add an additional item to the lists programmatically. The stored procedure returns the following StatusID and StatusName list.

1,Open 
2,Closed
3,In-Process
4,Under Review

I want to add the option "All Cases" with the StatusID of "-1" to the combobox but this value is not present in the database so I cannot pull it out from the stored procedure. How do I add it to the combobox in VBA? Thanks.

+2  A: 

One way is to use a Union Query:

SELECT Distinct -1 as ID, "All Cases" As What FROM SomeTable
UNION
SELECT <Real stuff>
Remou
That could certainly be one way to do it. Thank you! Wouldn't it better to add the additional row via VBA code so as to keep the stored procedure returning actual status values from the database?
webworm
Are you referencing a table/query or value list?
Remou
table/query ... data is in a SQL Server table and I am using a stored procedure to grab it.
webworm
I cannot see how you can add the row with VBA in that case, other than by building and SQL string.
Remou
The purpose of the procedure should be to return the selection list you want. You could use another procedure that has only the actual status values from the database in place of the <Real Stuff> section (I know, using the results of a procedure inside a select statement can't be done directly, but there are many workarounds.).
Jeff O