Code from combo box to field

access2010

Registered User.
Local time
Today, 01:00
Joined
Dec 26, 2009
Messages
1,117
Hello

We have been trying to copy data from a combo box to a field without any success.

===
Private Sub PortfolioCode_AfterUpdate()
' From the combo box "PortfolioCodek" Place the field data into Column # 1
Me.PortfolioCode = Me.Broker.Column(1)
End Sub
===

Could I please receive a suggestion on how to fix this problem

Thank you
Nancy
 

Attachments

Can't look at the sample right now, but the code should be in the after update event of the combo.
 
What exactly happens, any errors or what? Do you know that the Column starts at 0 ?
Are you sure you are referring to the correct one?
 
Broker is a text box and does not have any columns

if you want to copy the value of Portfolio Code.Column(1) of our combo into the textbox named Broker, this is the correct code

Private Sub PortfolioCode_AfterUpdate()
' From the combo box "PortfolioCodek" Place the field data into Column # 1
Me.Broker=Me.PortfolioCode.Column(1)
End Sub

column(1) of your combo is "PortfolioName". If you need to copy that value, just go on with above code
Otherwise, if you need to copy PortfolioCode, then use Me.PortfolioCode.Column(0)

Carlo
 
Otherwise, if you need to copy PortfolioCode, then use Me.PortfolioCode.Column(0)
Carlo

sorry just see now that the first column of your Combo is the bound one so .Column(0) is not required

Anyway, in my opinion the structure of your database is wrong
why do you repeat the same 2 columns (Broker and PortfolioCode) in both Investment and Portfolio tbls? I think you should not duplicate those values. You should create links between those fields then work with form and linked subform in order to fill automatically the values

In my opinion, also the primary key in portfolio tbl is wrong. It should be the AutoNumber (PortfolioID) and not PortfolioCode

Carlo
 

Users who are viewing this thread

Back
Top Bottom