Combobox w/query returns null value - why?

J

james

My design is pretty simple. Here it is:
table CURRENT_USER
CURRENT_USER, long integer, primary_key, used to store ENTITY_IDs

table ENTITY
ENTITY_ID, autonumber, primary_key
ENTITY_NAME, text, "last name, first name"
ENTITY_EMAIL, text "(e-mail address removed)"
ENTITY_PAGER, text currently empty

query qryENTITY returns
ENTITY_NAME, ENTITY_EMAIL, ENTITY_PAGER, ENTITY_ID

form frmCURRENT_USER record source CURRENT_USER table
combobox current_user_id control source CURRENT_USER
row source qryENTITY
column count 1 (ENTITY_NAME of qryENTITY)
bound column 4 (ENTITY_ID of qryENTITY)

I'm using no events, no code anywhere in the database,
nothing like that. What I want to get is a combobox that
returns the ENTITY_ID when the user can see the ENTITY_NAME.
This works on several other forms I'm using, and if I use
the Tables tab's data entry view I can enter a 2 and use
the form to see the associated name. However when I use
the combobox to pick another name the value NULL seems to
be returned. I gather this because the field's value
displayed changes to either all spaces or NULL and when I
attempt to store that record I get a message about the value
NULL not being valid for a primary key field. I know that
that is a correct error, but my question is:

Am I going about this the wrong way? I have several other
forms with comboboxes associated with a query just like this
one, several in fact that use this exact query, and they
all seem to work. So, if I am going about this correctly
then why is this one form's combobox returning NULL and if
this is bad design overall then how should I do it?

Thanks in advance for any help! Please post replies to the
newsgroup.
 
J

John Vinson

column count 1 (ENTITY_NAME of qryENTITY)
bound column 4 (ENTITY_ID of qryENTITY)

That's the problem. You're returning the fourth value in the list of
one. <g>

Make the ColumnCount 4, and set the ColumnWidths property so the
ENTITY_NAME is the only nonzero entry - e.g. 1.25;0;0;0.
 
J

james

John said:
That's the problem. You're returning the fourth value in the list of
one. <g>

Make the ColumnCount 4, and set the ColumnWidths property so the
ENTITY_NAME is the only nonzero entry - e.g. 1.25;0;0;0.

Thanks very much! Now off to fix the same thing in lots of different
comboboxes. ;v)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top