Change form caption

  • Thread starter Thread starter CD Tom
  • Start date Start date
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.
 
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"
 
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"
 
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.
 
Back
Top