Change form caption

C

CD Tom

I've been trying to change the Caption on a form and I keep getting the
message that it can't find the form 'MatchDescription' referred to in a macro
expression or Visual Basic code.
the code I'm using is
forms!matchdescription.Caption = "Test"
I'm trying to do this before I load the form, the form can be used in
different areas and I want to change the Caption for the different places I
use the form.
Thanks for any help.
 
S

Stuart McCall

CD Tom said:
I've been trying to change the Caption on a form and I keep getting the
message that it can't find the form 'MatchDescription' referred to in a
macro
expression or Visual Basic code.
the code I'm using is
forms!matchdescription.Caption = "Test"
I'm trying to do this before I load the form, the form can be used in
different areas and I want to change the Caption for the different places
I
use the form.
Thanks for any help.

"I'm trying to do this before I load the form". Therein lies the problem.
You're trying to set the caption too soon.

Another way to do this is to include the following code in the form's OnOpen
event:

Me.Caption = Me.OpenArgs

Then, when you use DoCmd.OpenForm, pass the caption string to the form via
the OpenArgs parameter. Eg:

DoCmd.OpenForm "MyFormName", OpenArgs:="My caption string"
 
C

CD Tom

That worked thanks.

Stuart McCall said:
"I'm trying to do this before I load the form". Therein lies the problem.
You're trying to set the caption too soon.

Another way to do this is to include the following code in the form's OnOpen
event:

Me.Caption = Me.OpenArgs

Then, when you use DoCmd.OpenForm, pass the caption string to the form via
the OpenArgs parameter. Eg:

DoCmd.OpenForm "MyFormName", OpenArgs:="My caption string"
 
S

Stuart McCall

CD Tom said:
Can you use the acdialog command with the openargs?

Yes, absolutely. It'll work whatever the configuration of the form (Popup,
Modal etc.).You can also do the same with a report if need be.
 

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