View Full Version : Setting combo box value problem


Matt_Burton
01-22-2002, 01:51 AM
Setting Combo box Value, Column Problem?

I'm trying to write some code to let users move from one form to another with a combo box value automatically set in the second form to an ID which has been created in the first form.

My combo box in the second form has 3 columns, ID, Name, Description.
The bound column is 1 which contains ID but isn't visible.

If we say a user creates a record with an ID of 511 in the first form I would like the second form to be opened
and the combo box set to show the Name & Description where ID = 511.

At the moment I can get the combo to show the 3rd item in the list which isn't what I want!!
I still need my row source of the combo box to be a select statement so they can be offered alternatives.

Here's my code so far...

Me.Combo80.Value = Me.Combo80.Column(1, 3)
Me.Repaint

Code At Present is....

Dim stDocName As String

stDocName = "frmAddNewActivityStep2"

DoCmd.Close
DoCmd.OpenForm stDocName

Forms!frmAddNewActivityStep2!Combo80.Value =
Forms!frmAddNewActivityStep2!Combo80.Column(1, 3)

Forms!frmAddNewActivityStep2.Repaint

Any ideas anyone?

Matt

Rich
01-22-2002, 02:28 AM
I don't think you can refer to two columns with one statement, use separate ones for each column. You should also be aware that the first column is actually 0 not 1, the third is (2).
HTH

Fizzio
01-22-2002, 02:49 AM
Also, you seem to be closing the active form with the combo on it before you set the new combo value based on that form.