dbTalk Databases Forums  

Form Combo box - multiple Control Source(s)?

comp.databases.ms-access comp.databases.ms-access


Discuss Form Combo box - multiple Control Source(s)? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
avi
 
Posts: n/a

Default Form Combo box - multiple Control Source(s)? - 04-06-2010 , 08:10 AM






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

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Form Combo box - multiple Control Source(s)? - 04-06-2010 , 09:34 AM






avi wrote:
Quote:
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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.