| re: Setting Value of Combo Box on Subform
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Reference a subform from the current form:
Me!frmStageTrack_sub!CboTermID
or
Me!frmStageTrack_sub.Form!CboTermID
Why don't you just set the ComboBox's Default property to 1? If the
ComboBox is a bound control, setting its Value property to 1 means you
are creating a new record in the subform - are all the required fields
getting the values they need?
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBRFkMP4echKqOuFEgEQLRZwCg+sMvPH2FI2p61CRUudSEaq TkPj4AoMK2
7L9y9L7TaA2oSb0XDpEj0uRr
=FrAT
-----END PGP SIGNATURE-----
Rick wrote:[color=blue]
> I have a main form called frmDemo with a subform frmStageTrack_Sub. On
> the subform is a Combo Box CboTermID. The frmDemo is tied to tblDemo
> and the frmStageTrack_Sub is tied to tblStageTrack. What I would like
> to do is when a new record is created in frmDemo I would like to set
> the CboTermID on the subform to a default value, say 1, without the
> user having to set focus on the subform and selecting an item from the
> combo box. Right now if the user does not select a TermID on the
> subform no record is created in the StageTrack table when a new record
> is created in frmDemo. I only wish to set a default value if the
> TermID is Null.
> I have tried the following in the AfterUpdate event of frmDemo
>
> Private Sub Form_AfterUpdate()
> If IsNull(Me.Forms.frmDemo.frmStageTrack_Sub.Form.Cbo TermID) Then
> Forms.frmDemo.fromStageTrack_Sub.CboTermID = 1
> End If
>
> End Sub
>
> But I keep getting a runtime error. What is the correct way to set the
> CboTermID from the Main form?
>[/color] |