subform cmbo box default

C

Cynthia

How can I set a default on a combo box in a subform per a field that is set
in the main form? I am already setting the record source on the subform

Me.WireAssignFrm.Form.RecordSource = "Select * from elewires where cableid =
" & ctid & ""

I need the cmbo box cmbTB in the subform to have a default the same as the
name tTB_Name in the main form.

Thank you in advance for any help you can give me on this
 
K

Ken Snell MVP

Is this to be the default value for new records only? You could put code in
the same event procedure that sets the subform's RecordSource to do this:

If Len(Me.WireAssignFrm!cmbTB.Value & "") =0 Then -
Me.WireAssignFrm!cmbTB.Value = Me.tTB_Name
Me.WireAssignFrm!cmbTB.DefaultValue = Chr(34) & _
Me.tTB_Name & Chr(34)
 
M

Marshall Barton

Cynthia said:
How can I set a default on a combo box in a subform per a field that is set
in the main form? I am already setting the record source on the subform

Me.WireAssignFrm.Form.RecordSource = "Select * from elewires where cableid =
" & ctid & ""

I need the cmbo box cmbTB in the subform to have a default the same as the
name tTB_Name in the main form.


Try using a line of code in the tTB_Name text box's
AfterUpdate event and in the main form's Current event:

Me.WireAssignFrm.Form.combo0.DefaultValue = """" &
tTB_Name & """"

If that doesn't work, it could be because the combo box's
BoundColumn is an id field and not the name. In that case,
try using the main form's id text box instead of the name
text box.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top