form is saving id not name (1 Viewer)

kobiashi

Registered User.
Local time
Today, 15:35
Joined
May 11, 2018
Messages
258
I have created a form to create new users, when you press save, it works, save all the details in the query, however i have created a couple of combo boxes, and set them like

bound column 1
column count 2
column width 0";1"


but when i view the query, the form has saved the id and not the name fro the combo boxes, i cant seem to find whats the issue
 

isladogs

MVP / VIP
Local time
Today, 15:35
Joined
Jan 14, 2017
Messages
18,207
If the name is in the second column, you need to reference that.
As column numbers are zero based use me.comboboxname.Column(1).

However, you can't do that in a query so use a variable such as strName to grab the value, then use the variable or a function based on that in your query.
 

June7

AWF VIP
Local time
Today, 06:35
Joined
Mar 9, 2014
Messages
5,463
Why would you not save the ID? Isn't it the primary key? If you don't want to save ID then don't include it in the comobobox RowSource.

Why are you running a query to save record? Is form not bound to table?
 

Gasman

Enthusiastic Amateur
Local time
Today, 15:35
Joined
Sep 21, 2011
Messages
14,217
I believe that is how it is meant to work. You save the key not the description.
You then use that key to get the description back.

That way, if you change the description, you do not have to change any links between tables?

At least that is how I have always done it.
I *always* make the first field the ID/key field, and then have my other columns after that, some of which might not be displayed as well.

HTH

I have created a form to create new users, when you press save, it works, save all the details in the query, however i have created a couple of combo boxes, and set them like

bound column 1
column count 2
column width 0";1"


but when i view the query, the form has saved the id and not the name fro the combo boxes, i cant seem to find whats the issue
 

ColinEssex

Old registered user
Local time
Today, 15:35
Joined
Feb 22, 2002
Messages
9,117
Why does this thread qualify as "site suggestions"?

Col
 

June7

AWF VIP
Local time
Today, 06:35
Joined
Mar 9, 2014
Messages
5,463
OP selected wrong forum. A moderator can move thread.
 

ColinEssex

Old registered user
Local time
Today, 15:35
Joined
Feb 22, 2002
Messages
9,117
OP selected wrong forum. A moderator can move thread.

I am aware of that. I have been here since around 1999:rolleyes:

The thread however has been here since 11/5. I'm surprised an eagle eye moderator hasn't spotted it, they're very quick to ban people for little reason.

Col
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 10:35
Joined
Feb 19, 2002
Messages
43,199
but when i view the query, the form has saved the id and not the name fro the combo boxes, i cant seem to find whats the issue
This is not an issue, That is EXACTLY the way it is supposed to work. When creating a relationship from one table to another, you store the PRIMARY KEY of the other table NOT a data field. So in tblOrder, you would store CustomerID NOT customer name or any other piece of data.

When you need to display the customerName on a form, you will usually use a combo but on a report, you would use a query that joins tblOrder to tblCustomer on CustomerID and that allows you to display not only the CustomerName but also his phone number and address if you want to.

I am only commenting because the others equivocated rather than making a simple declarative statement - this is how it is supposed to work. Nothing is wrong.
 

Users who are viewing this thread

Top Bottom