A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Label Caption on Subform from Textbox Value on Main Form



 
 
Thread Tools Display Modes
  #1  
Old April 13th, 2010, 07:23 PM posted to microsoft.public.access.forms
steve p
external usenet poster
 
Posts: 40
Default Label Caption on Subform from Textbox Value on Main Form

On sfmProducts I have Label1 that is associated with txtColumn1. On
frmProducts I have txtColumnCaption1. I would like to have sfmProducts
display in datasheet view and have the caption of Label1 on the subform set
to the value of txtColumnCaption1 on the main form.

If I enter the following formula as the Caption of Label1 then the column
heading in datasheet view displays the formula itself.

=[Forms].[frmProducts]![txtColumnCaption1].[Value]

If I enter the same formula for the Control Source of txtColumn1 then the
value from the main form does indeed display.

What am I doing wrong?
  #2  
Old April 13th, 2010, 10:41 PM posted to microsoft.public.access.forms
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default Label Caption on Subform from Textbox Value on Main Form

To use the expression =[Forms].[frmProducts]![txtColumnCaption1], change the
label to a textbox. Set its enabled property to No and its locked property
to Yes.

To use a label instead, write some code like:
Me.Label1.Caption =[Forms].[frmProducts]![txtColumnCaption1]
Where to put that code?
Every time txtColumnCaption1 changes, the value of Label1 on the subform
needs to change.
What makes the value of txtColumnCaption1 change?


You will find that you don't need to put .[Value] in the expression.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"Steve P" wrote in message
news
On sfmProducts I have Label1 that is associated with txtColumn1. On
frmProducts I have txtColumnCaption1. I would like to have sfmProducts
display in datasheet view and have the caption of Label1 on the subform
set
to the value of txtColumnCaption1 on the main form.

If I enter the following formula as the Caption of Label1 then the column
heading in datasheet view displays the formula itself.

=[Forms].[frmProducts]![txtColumnCaption1].[Value]

If I enter the same formula for the Control Source of txtColumn1 then the
value from the main form does indeed display.

What am I doing wrong?




  #3  
Old April 13th, 2010, 10:49 PM posted to microsoft.public.access.forms
Rob Parker[_3_]
external usenet poster
 
Posts: 173
Default Label Caption on Subform from Textbox Value on Main Form

Hi Steve,

The thing you're doing wrong is using a label control. As you've found, it
cannot evaluate an expression in its caption, where a textbox can evaluate
an expression set as its ControlSource. Simply change the label to a
textbox; you can set its propertyies to Enabled = No and Locked = Yes to
prevent access to it, and when the form displays users will not know the
difference. About the only thing you lose is the ability to link it to a
textbox, so that they move together; but once you've designed your form,
that's really irrelevant.

HTH,

Rob


Steve P wrote:
On sfmProducts I have Label1 that is associated with txtColumn1. On
frmProducts I have txtColumnCaption1. I would like to have sfmProducts
display in datasheet view and have the caption of Label1 on the
subform set to the value of txtColumnCaption1 on the main form.

If I enter the following formula as the Caption of Label1 then the
column heading in datasheet view displays the formula itself.

=[Forms].[frmProducts]![txtColumnCaption1].[Value]

If I enter the same formula for the Control Source of txtColumn1 then
the value from the main form does indeed display.

What am I doing wrong?



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:35 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.