subform cmbo box default

  • Thread starter Thread starter Cynthia
  • Start date Start date
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
 
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)
 
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.
 
Back
Top