Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does Anyone know how to change text of a label on a form .. 1

Status
Not open for further replies.

LizardKingSchwing

Programmer
Oct 12, 2001
96
0
0
NL
I need to change the text of a label on a form in VBA code

Cheers

LK--<
 
Hi LK,

labelName.Caption = &quot;newName&quot; Hope this is ok. If not, just let me know.

Nick (Everton Rool OK!)
 
The label is not on the current form it is on a form which I wish to open, basically I need to set up the form with all the info. b4 i display it

Cheers

LK--<

(LIVERPOOL RULE 2)
 
Use the OnOpen action to activate the function/coding you require.

Then assign as explained earlier

Ian
 
Basically

I have a Form and on it some controls , when I press a button , based on the controls selected and date I open up a form with 2 graph objects , I build up the tables for these graphs b4 I open the graph form , however I need to also show more information below each graph e.g Max , Avg based on the gaphs tables.
I have labels setup for these values and I was going to just update the label to the values b4 I open the graph form


This is why the OnOpen action might not work

Cheers

LK--<
 
LK,

How about using the syntax:

forms!formName!LabelName.caption Hope this is ok. If not, just let me know.

Nick (Everton Rool OK!)
 
I try


Forms!GraphsDaily!MaxISDNin.Caption = &quot; 10&quot;

Where GraphsDaily is Form Name and MaxISDNin is label name

...

I get this error when I try to do that it is a bit odd

&quot;ISDN Watch Reports can't find the form 'GraphsDaily' referred to in a macro expression or Visual Basic code.&quot;

ISDN Watch Reports is the name of the app



 
GraphsDaily is correctly spelt?

Try right clicking the form, choosing rename and copy the name. Paste the name into you code. Hope this is ok. If not, just let me know.

Nick (Everton Rool OK!)
 
In your case, it may be more appropriate to use textbox instead of labels. Then you can bound the text box to some fields that can be pre updated b4 the form is open.

 
I assume the form is already open at this point? The form needs to be open before you can try to assign any values to control witihin the form.
 
Sorry LK,

From what Taff has said, I got it wrong. I forgot about the form having to be open. Hope this is ok. If not, just let me know.

Nick (Everton Rool OK!)
 
Oh no its not open ...Doh .. does it need to be
I mean can I not update the label b4 it is displayed...
 
The form needs to be opened first but...

I assume your using the OnClick action from the button and if you put the code in after the open cmd then the users won`t be able to notice the difference. If the code to get the data takes a little while then determine that first and and use variables to assign the values later on to the individual labels.

OnClick()

dim MaxVal as Double

MaxVal = (Insert the data source here)

Docmd.OpenForm &quot;Graphs&quot;
Forms!Graphs!labelMax.Caption = MaxVal

End sub


Hope this helps
 
Suggestion: Place the value you want to appear in your label in a textbox (with visablem property set to &quot;no&quot;) on the form you are using to call up the new form. In the &quot;On Open&quot; event of the new form, have the new form look back at the other (forms!frmCallingForm!invisiblebox) and place that value in the caption property of your label in the newly opened form. This has worked very reliably for me in the past when I needed to pass a value (or many values) back and forth between forms that called one another. &quot;Databases That Work The Way You Do!&quot;
 
I tried that Taff07 but no luck it did not change the value

fynder I have 6 items I need to show for each graph and I have 2 graphs per form , and I have 4 graph forms so that kinda rules out that one ehm...

Any more suggestions


ThanX

LK--<
 
LK,

Is it possible for you to send me an example of the forms?

If so use my E-Mail address

ian.oldreive@barclays.co.uk

No data sould be required just give the neccesary parts to run what you have so far.

Ian
 
Can you let me know if/when you get it cos my internet / emails acting up

chiz

LK--<
 
No problem Will post on here when I receive. Hasn`t arrived yet though.
 
You can have 24 of those hidden textboxes if you want to write the code to manage them. You are not limited to one textbox to pass info back and forth with. &quot;Databases That Work The Way You Do!&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top