How do you set a form varaible from Modual

R

Richard Albrecht

Hi,

I want to set a Labels Caption property from a modual. In Delphi I would
do something like this:

Form1.LabelName.Cation = "This is a test"

However I can't seem to figure out how to do this in VBA.

Help!

Thanks

Rich
 
D

Dirk Goldgar

Richard Albrecht said:
Hi,

I want to set a Labels Caption property from a modual. In Delphi I
would do something like this:

Form1.LabelName.Cation = "This is a test"

However I can't seem to figure out how to do this in VBA.

Help!

Thanks

Rich

I assume the module in question is not the form's own class module. So,
assuming Form1 is currently open, you'd write this:

Forms!Form1!LabelName.Caption = "This is a test"
 
R

Richard Albrecht

What if you want to set it before you display it? ie the form is not open
yet.

Thanks

Rich
 
D

Dirk Goldgar

Hal said:
Try

Forms("FormName").LabelName.Value = "This is a test"

Sorry, that won't work -- the control reference will work but the
property is wrong. The Value property isn't the same as the Caption
property, and a label control doesn't have a Value property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top