Solved How to enter data linked to one entered in combobox? (1 Viewer)

QMarshal

New member
Local time
Today, 02:42
Joined
Oct 28, 2021
Messages
5
Hi! Thank you so much for looking this one up! Ran into a simple problem learning MS Access.

Created a simple form, comboboxes and such, Linked form and comboboxes to needed columns. But! In Data source property I set another table, joined to main one, so form, once displayed, will show understandable text, instead of IDs, that populate my main table. The problem is that now, when user tries to select text value, while working with form, Access tries to set numeric value of ID in my main table to text value of selected option. I need to find a way to reconvert text through 2nd table to ID, that I'd need to get into my main table. Thanks in advance for help. Can't get screenshots cause working in another lang, so there's no point.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 16:42
Joined
Aug 30, 2003
Messages
36,125
Make sure the bound column property of the combo reflects the ID column rather than the text column.
 

bob fitz

AWF VIP
Local time
Today, 00:42
Joined
May 23, 2011
Messages
4,721
I don't understand what you're trying to do exactly, but you may find it helpful to know that the first column of a combo is often hidden but holds the ID of the table. The user actually selects a text value shown in the second column but the data saved is the ID from the first column
 

QMarshal

New member
Local time
Today, 02:42
Joined
Oct 28, 2021
Messages
5
Make sure the bound column property of the combo reflects the ID column rather than the text column.
As far as I understand, bound column reflects where in the end do I want to write data to. It is set to ID column, which is right as I want to write to main table ID that corresponds to text, entered by user (link through 2nd table). It just doesn't know that it needs to convert back to ID from text. I could write a small query for that, but there should be less spaghetti way
 

QMarshal

New member
Local time
Today, 02:42
Joined
Oct 28, 2021
Messages
5
1635429033658.png

Scheme of things
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 19:42
Joined
May 21, 2018
Messages
8,527
he problem is that now, when user tries to select text value, while working with form, Access tries to set numeric value of ID in my main table to text value of selected option. I need to find a way to reconvert text through 2nd table to ID, that I'd need to get into my main table.
The trick is to return and bind the ID column, but hide it by setting its width to 0
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 19:42
Joined
May 21, 2018
Messages
8,527
Example
Select ID, Text from someQuery
ColumnCount: 2
Bound Column:1
Column Widths: 0"; 1"

You will only see the text but store the ID.
 

QMarshal

New member
Local time
Today, 02:42
Joined
Oct 28, 2021
Messages
5
Red is how it wrongly goes, trying to get text into ID field. Green is how it supposed to go.
My data field is main.ID as field of table my form is assigned to.
 

QMarshal

New member
Local time
Today, 02:42
Joined
Oct 28, 2021
Messages
5
Example
Select ID, Text from someQuery
ColumnCount: 2
Bound Column:1
Column Widths: 0"; 1"

You will only see the text but store the ID.
Seen it in a turorial, but thought it's wacky AF. It it really how ppl do it? Wild.
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 19:42
Joined
May 21, 2018
Messages
8,527
Yes. It is exactly how to do it. AFAIK it is the only way without lots of code and an ubound control.
 

Users who are viewing this thread

Top Bottom