Link to home
Create AccountLog in
Avatar of Michael Katz
Michael KatzFlag for United States of America

asked on

Forms with Unbound sections / fields

I have an Form Header Unbound Combo Box 'SalesComponent' with a RowSource as a sql statment..

How can i link a field that i have in the Detail section to the Unbound record in the Form Header...This record needs to change every time a new selection is made within this 'SalesComponent' Combo Box..

I am sure it is simple...but I just can get it right
Avatar of Bitsqueezer
Bitsqueezer
Flag of Germany image

Hi,

it's not really a link, but you can simply use

Me.Recordset.FindFirst "ID=" & Nz(Me.NameOfYourCombobox,0)

ID is the name of the field in the table which should contain the primary key (usually an Autoincrement ID) which is also the first column in the unbound combobox as hidden column.

Use this line in the "AfterUpdate"-Event of the unbound combobox.

Cheers,

Christian
ASKER CERTIFIED SOLUTION
Avatar of Vadim Rapp
Vadim Rapp
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Check with this: table a(f1, ...).
Combo name: cmdRecord in Form header.
Private Sub cmdRecord_AfterUpdate()
    Me.RecordSource = "select * from a where f1=" & cmdRecord
End Sub

Open in new window

I think, some clarification is in order. My suggestion was based on understanding your question as how to make an unbound text field on the form to have the same value as selected in the combobox.

Others' suggestions show how to make the form to navigate to the record where bound textbox would have the same value as selected in the combobox.

From your initial question it's not 100% clear which one is the case.