I have a form that contains a subform displayed in datasheet view. I want to
be able to change several column headings of the subform depending on values
selected by the user on the main form. The column headings appear to be
coming from the .Name property of each object in the subform. Changing this
when you have code tied to the objects does not seem a good idea. Any tips on
how to do this using other methods?
tina - 17 Aug 2005 06:07 GMT
in the subform's design view, take a look at the Caption property of the
Label attached to each control. i'm guessing that the name of the control
matches the Caption of the attached label.
if you want a particular label's caption changed immediately after the value
in a mainform control is changed, then add code to the mainform control's
AfterUpdate event, as
Dim strCaption As String
Select Case Me!MainFormControlName
Case "something"
strCaption = "x"
Case "something else
strCaption = "y"
Case Else
strCaption = "z"
End Select
Me!SubformCONTROLName!SubformLabelName.Caption = strCaption
look up Select Case in Access VBA Help, so you'll understand how it works.
hth
> I have a form that contains a subform displayed in datasheet view. I want to
> be able to change several column headings of the subform depending on values
> selected by the user on the main form. The column headings appear to be
> coming from the .Name property of each object in the subform. Changing this
> when you have code tied to the objects does not seem a good idea. Any tips on
> how to do this using other methods?
Bruce - 18 Aug 2005 23:40 GMT
Thanks, this was a huge help! This "attached labels" was the tip I was
looking for.
tina - 19 Aug 2005 02:02 GMT
you're welcome :)
> Thanks, this was a huge help! This "attached labels" was the tip I was
> looking for.
Dirk Goldgar - 17 Aug 2005 06:27 GMT
> I have a form that contains a subform displayed in datasheet view. I
> want to be able to change several column headings of the subform
[quoted text clipped - 3 lines]
> does not seem a good idea. Any tips on how to do this using other
> methods?
If the controls on the form have attached labels, the captions of those
labels override the names of the controls. So you could change the
captions of those labels at run time. The attached label of a control is
a member of that control's Controls collection. So you could write
something similar to this example:
With Me.Subform1.Form
!ID.Controls(0).Caption = "New ID Header"
!Desc.Controls(0).Caption = "New Desc Header"
!Modified.Controls(0).Caption = "New Modified Header"
End With
(where ID, Desc, and Modified are controls on the form).

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)