Clear the contents of a sub-form

U

Ultraviolet47

Hi

I have been able to clear the contents of my form using

[fieldnamel].Value = ""

However, I cannot get code to reset the contents of my subforms to a
blank combo box (the sub forms consist of one combo box and the other
has a combo box and date fields with default dates). Does anyone have
any ideas for code please?

Also, I had a close button on the main form that prompted to save the
changes if dirty-now I have added the subforms, it has ceased to work
and is automatically saving-what has putting on the subforms changed?

Thanks in advance for you help!
 
U

Ultraviolet47

PS I have tried "Add New Record" to get it to clear the sub forms as
well-however this saves the data before clearing it all and I don't
want this.

Ta muchly
 
D

Douglas J. Steele

To ensure that's nothing selected in a combo box, you need to set it to
Null, not ""

To refer to a control on a subform from the parent form, you need to use:

Me!NameOfSubformControlOnParentForm.Form!NameOfControlOnSubform

Depending on how you added the subform to the parent form, the name of the
subform control may be different than the name of the form being used as a
subform.

To refer to a control on a subform from some other form, you use:

Forms!NameOfParentForm!NameOfSubformControlOnParentForm.Form!NameOfControlOnSubform
 
U

Ultraviolet47

Hi

Thanks very much for your reply.

I have a subform called Subfrm_Rat on Frm_AddSponsors. The subform has
the combo box field RatID in Combo1.

I have tried Me!RatID.Form!RatID = Null and Me!Combo1.Form!Combo1 =
Null but it says it cannot find the RatID field or Combo1 field? I
have also tried these fields in the longer bit of code you gave to do
it form other forms and no luck.

I also have a subform called Subfrm_Payee on Frm_AddSponsors with the
combo box PayeeID and field PayeeID. Aagain, I've tried putting these
fields in the code, but it says it cannot find the fields?

Am I on the right track? What am I doing disasterously wrong?! :)

Thanks for your help
 
U

Ultraviolet47

Hi

Fixed it, I actually used some code I had in an older version on my
db:

Me.Child67.Form.Combo1.Value = Null
Me.PayeeID.Form.PayeeID.Value = Null

Thanks
 
Top