RE: Adding to a combo box list that is based on a table
- From: Pat <Pat@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 8 May 2008 10:38:02 -0700
I want the default selection to be the add new. From my testing (maybe my
fault) I am not able to get this on the combo box. It is blank. I set the
row source to a table, set the default value to "[Add New]". Am I missing
something?
"Klatuu" wrote:
Even though you are using mutliple tables for your query, it still return.
rows made up of the fields in the query. The UNION part just has to match
the list of fields returned by the query.
But, I am curious as to why you think Jeff's suggestion will not work for
you. It really is the easier way to do this. If you can explain why you
think that, perhaps we can offer a suggestion on how to make it work.
--
Dave Hargis, Microsoft Access MVP
"Pat" wrote:
Again thanks for your reply. I did a little research and the UNION appears
to require as you have said like tables. Since my query is referencing 3
seperate tables, how would I include the UNION statement? I am a little
green in this area, your help is very much appreciated.
"Klatuu" wrote:
You can do this with an UNION query. You just have to create dummy values.
With a Union Query, there has to be an equal number of fields and the field
data types have to match. You also need to have an ORDER BY that will cause
your [Add New Item] field to be the first item in the list. Here is an
example that may help. Assume you have an Autonumber field as the first
field you will want sort on, and a description field to display in the combo,
then a text field and another Long Integer field in the table. You can mock
up the Union side:
SELECT [KeyFld], [DescriptionField], [BarrellType], [BarrellLength] FROM
tblGuns UNION SELECT 0 as Dummy, "[Add New Item]" As [DescriptionField], ""
As [BarrellType], 0 As [BarrellLength] FROM tblGuns ORDER BY [KeyFld];
Then to make [Add New Item] the default, use the form Current Event to
select then item. This assumes the Bound Column property of your combo is 1:
Me.MyCombo = 0
--
Dave Hargis, Microsoft Access MVP
"Pat" wrote:
I would like to be able to have my combo box have an item at the top and be
the default selection. Something like "[Add New Item]". The row source is a
query to a few tables. I can't see a way without have a record in the source
table.
And if it makes any difference, the source is a query that using a concat of
several fields to display, but the bound column is column 2, the record ID.
Here is the query I am using for the source.
SELECT [a_caliber] & " " & [dbtbullet_lst].[b_weight] & "g " &
[dbtbullet_lst].[b_mfg] & " " & [dbtbullet_lst].[b_type] & ", " & [a_charge]
& "g " & [dbtpowder_lst].[mfg] & " " & [dbtpowder_lst].[desc] AS expr1,
dbtReloadRecipe.recipe_id, dbtReloadRecipe.a_caliber FROM dbtPowder_lst INNER
JOIN (dbtBullet_lst INNER JOIN dbtReloadRecipe ON dbtBullet_lst.bulletID =
dbtReloadRecipe.a_bulletID) ON dbtPowder_lst.powderID =
dbtReloadRecipe.a_powderID WHERE
(((dbtReloadRecipe.a_caliber)=[Forms]![frmMaintainReloads]![r_caliber]));
Any ideas?
- Follow-Ups:
- References:
- Prev by Date: Re: Is there a list of ForeColor codes?
- Next by Date: Re: From Dialog, Find record, If No Match then New Record
- Previous by thread: RE: Adding to a combo box list that is based on a table
- Next by thread: RE: Adding to a combo box list that is based on a table
- Index(es):
Relevant Pages
|
Loading