From: avi on
Hi I have a form with combo box that pulls 4 columns from the table A.

I want to pass selected row (from pulled values) to another table
(table B) into the corresponding columns.
(Basically some sort of SQL "update table B where 4 conditions from
table A are met").

But since "Control source" of the CboBox accepts only 1 value I cant
figure this out...?
Can you please advise? TIA
From: Salad on
avi wrote:
> Hi I have a form with combo box that pulls 4 columns from the table A.
>
> I want to pass selected row (from pulled values) to another table
> (table B) into the corresponding columns.
> (Basically some sort of SQL "update table B where 4 conditions from
> table A are met").
>
> But since "Control source" of the CboBox accepts only 1 value I cant
> figure this out...?
> Can you please advise? TIA

If I have a form called MyForm, and a combobox called ComboFilter, I can
reference the first two columns like this
MsgBox Forms!MyForm!ComboFilter.Column(0) & vbNewLine & _
Forms!MyForm!ComboFilter.Column(1)

In the query builder tho it doesn't like a property like .Column(). But
it doesn't mind a reference to the combo field.
Forms!MyForm!ComboFilter
tho.

The first element of a row in a combo starts at 0. So if you had 5
columns, the last element would be 4.

In your form you could place 4 invisible fields. Fld1...Fld4. When an
op presses a command button to update, you could do
Me.Fld1 = Me.YouComboBoxName.Column(0)
Me.Fld2 = Me.YouComboBoxName.Column(1)
Me.Fld3 = Me.YouComboBoxName.Column(2)
Me.Fld4 = Me.YouComboBoxName.Column(3)
Docmd.SetWarnings False
Docmd.OpenQuery "YourQueryName"
Docmd.SetWarnings True

In your query you make a reference like
Forms!MyFormName!Fld1

You could write the SQL string as well
Dim s As String
s = "UPDATE Customers SET " & _
"LastName = """ & [Forms]![MyForm]![MyCombo].Column(1) & """, ...
Docmd.RunSQL s