From: Mark Kubicki on
I have a form with some simple code behind it which reads like this:

with Forms![frmNextFixtureTypeOption]
.[lblNextAlpha].Caption = strNextAlpha
.[lblNextNumeric].Caption = strNextNumeric
end with

stDocName = "frmNextFixtureTypeOption"
DoCmd.OpenForm stDocName, , , stLinkCriteria

the second part (where I open the form) works fine, but the first (where I
set the caption for 2 of the controls) does not - it returns an error
"can't find form"...


as always, many thanks in advance,
mark


From: John W. Vinson on
On Wed, 24 Mar 2010 13:42:54 -0400, "Mark Kubicki" <Mark(a)TillotsonDesign.com>
wrote:

>I have a form with some simple code behind it which reads like this:
>
> with Forms![frmNextFixtureTypeOption]
> .[lblNextAlpha].Caption = strNextAlpha
> .[lblNextNumeric].Caption = strNextNumeric
> end with
>
> stDocName = "frmNextFixtureTypeOption"
> DoCmd.OpenForm stDocName, , , stLinkCriteria
>
>the second part (where I open the form) works fine, but the first (where I
>set the caption for 2 of the controls) does not - it returns an error
>"can't find form"...

That's because it isn't open yet. The Forms! collection contains only *OPEN*
forms.

Move the first four lines after the OpenForm event line.
--

John W. Vinson [MVP]