Solved Fill cell in table based on Combo Box (1 Viewer)

Romio_1968

Member
Local time
Today, 14:48
Joined
Jan 11, 2023
Messages
126
Hello

I have two tables:
One (Books) containg the fields BookID, Title, Domain. ClassCode.
The second (Domains) contais the fields ClassID, ClassCode, Domain
The two tables are in a one-to-many relationship, so I can use multiple Titles for the same ClassCode.
I have a form to add data in the Books table.
I have a Combo Box to select the Domain, via a select query from the Domains table.

I want the ClassCode from table Books to be filled with the correspondent ClassCode from the Domain table, based on the value selected in the Combobox.
The select query used to populate the combo has two colums (Domain and ClassCode), sorted by Domain.

Thank you
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:48
Joined
Sep 21, 2011
Messages
14,311
Bring on the classcode as an additional column in the combo and populate from that. Combo columns start at 0.
 

Romio_1968

Member
Local time
Today, 14:48
Joined
Jan 11, 2023
Messages
126
Gasman, thank you. Can you be more speciffic please?
How should I do that?

The combo row source is:

SELECT Domains.Domain, Domains.Class_Code FROM Domains ORDER BY Domains.Domain;

How can I add the additional column (probably the ClassCode)
Let us assume that the Combo field name is Combo and the textbox to be filled is TB1 and will contain the value to be written in a cell called ClassCode_1 from Books table.
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:48
Joined
Sep 21, 2011
Messages
14,311
Well you already have the classcode in your combo?
Me.tb1 = me.combo.column(1)

Get your names correct as well, one minute it is classcode then it is class_code?
Tables do not have cells, they have fields. :( Bind that field to TB1
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:48
Joined
Feb 19, 2002
Messages
43,293
Since you shouldn't normally store lookup fields, you need to prevent them from accidentally being updated. That means you need to set the Lock property of the classcode control to Yes. This prevents the two fields from getting out of sync.
 

Users who are viewing this thread

Top Bottom