Unable to set label caption or textbox control source on report at runtime

S

SUZYQ

I have a report where I want to change the caption of a label or the
control source of a textbox based on some sort of criteria at runtime.
I'm using Access 2002.

I'm trying to use the Report's On Open event. When I type in
Me.mytextbox.ControlSource = Forms!frmName!controlname Access thinks
it's a parameter and gives me a prompt for it.
I know this should work. Can't figure out why it's not.
 
D

Douglas J. Steele

What's in the textbox? A value or a SQL expression? ControlSource expects a
SQL Statement, unless you precede what's there with an equal sign.

If it is just a value you're trying to use, try

Me.mytextbox.ControlSource = "=Forms!frmName!controlname"
 
S

SUZYQ

That did it. Thanks so much. Just out of interest, how come you don't
get control source as an option in the dropdown after you type
Me.mytextbox. ?
 
D

Douglas J. Steele

SUZYQ said:
That did it. Thanks so much. Just out of interest, how come you don't
get control source as an option in the dropdown after you type
Me.mytextbox. ?

Not sure, but I suspect that, to save resources, Access doesn't actually
determine to what type of Control you're referring and simply presents a
list of what properties are common to all controls. Since not all controls
have a Control Source property, it doesn't make the cut.
 

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