Solved Storing Different Column Value of Combo Box in the Control Source (2 Viewers)

Pac-Man

Active member
Local time
Today, 17:59
Joined
Apr 14, 2020
Messages
408
Hello,

I've a combo box in my form and value of column 2 is being used in generating other number on the form due to which I've to set bound column to 2. But for the Control Source, I want to store value of column 1 (PK) because column 2 is not unique.

What I know is I have to set cboGroupCode to unbound with bound column 2 so that value from column 2 can be used in generating other number on the form. I will also need to create a bound text box (visible properties set to No) to use this text box to store value of column 1 of cboGroupCode in control source. I also know that I have to use after update event of cboGroupCode. What I don't know is, what would be the vba code or macro. Or what I think I know is totally incorrect there should another way of doing it.

Can somebody please guide me?

Best Regards,
Abdullah
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:59
Joined
Oct 29, 2018
Messages
21,357
Hi. I would keep the Bound Column to 1 and use the Control Source, but use the Column property to get the value of the 2nd column.
 

Pac-Man

Active member
Local time
Today, 17:59
Joined
Apr 14, 2020
Messages
408
Hi. I would keep the Bound Column to 1 and use the Control Source, but use the Column property to get the value of the 2nd column.
Thanks for reply. By column property you mean by column widths in format properties? If yes, I'm using these properties to show and hide multiple columns in cbo. But if bound column is set to 1, my generated number is incorrect which is being generated by following:
"[GroupCode]"/[ReportPartialNo]"
ReportPartialNo is being obtained by DMax functions which is irrelevant here. If I set bound column to 1 then my generated no is like 1/001 whereas i want is like Group1/001 because bound column is 1. When i set to bound column 2, than it generate correct. So that is why i want to set bound column of cboGroupCode to 1 whereas store value of column 2 in table.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:59
Joined
Oct 29, 2018
Messages
21,357
Thanks for reply. By column property you mean by column widths in format properties? If yes, I'm using these properties to show and hide multiple columns in cbo. But if bound column is set to 1, my generated number is incorrect which is being generated by following:
"[GroupCode]"/[ReportPartialNo]"
ReportPartialNo is being obtained by DMax functions which is irrelevant here. If I set bound column to 1 then my generated no is like 1/001 whereas i want is like Group1/001 because bound column is 1. When i set to bound column 2, than it generate correct. So that is why i want to set bound column of cboGroupCode to 1 whereas store value of column 2 in table.
Hi. No, I mean like this. As a Control Source of an unbound Textbox:

=[ComboboxName].[Column](1)
 

Pac-Man

Active member
Local time
Today, 17:59
Joined
Apr 14, 2020
Messages
408
Hi. No, I mean like this. As a Control Source of an unbound Textbox:
=[ComboboxName].[Column](1)
What I understand from your comment is, i should let the cbo bound to control source and with bound column 1. To generate my desired number, i should use unbound text box with control source =[ComboboxName].[Column](2) because i want column 2 value in generated number and then use "[Unbound txt box name]"/[ReportPartialNo]" to generate desired number.

Am I right?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:59
Joined
Oct 29, 2018
Messages
21,357
What I understand from your comment is, i should let the cbo bound to control source and with bound column 1. To generate my desired number, i should use unbound text box with control source =[ComboboxName].[Column](2) because i want column 2 value in generated number and then use "[Unbound txt box name]"/[ReportPartialNo]" to generate desired number.

Am I right?
Yes, you're right except for the number in the Column(x) expression. It should be 1 for column 2 because column 1 is (0).
 

Users who are viewing this thread

Top Bottom