Abraham-
You can use a variable to hold a control name, but the syntax will be
slightly different, and you cannot reference the control until after the
form is open. Perhaps like this:
Select Case intSelectedControl
Case 1
stDocName = "frmProductGroup1"
stControlName = "txtGroup1"
stControlValue = "Hello"
Case 2
stDocName = "frmProductGroup2"
stControlName = "txtGroup2"
stControlValue = "Goodbye"
..
..
..
End Select
DoCmd.OpenForm stDocName
Forms(stDocName).Controls(stControlName) = stControlValue
John Viescas, author
"Building Microsoft Access Applications"
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
> -----Original Message-----
> From: Abraham [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 23, 2005 7:18 AM
> To: [email protected]
> Subject: [ms_access] Referring To A Control In A Closed Form
>
>
>
>
> Hi,
> I have code that opens different forms using Select case as follows:
>
> Select Case intSelectedControl
> Case 1
> stDocName = "frmProductGroup1"
>
> Case 2
> stDocName = "frmProductGroup2"
>
> ..
> ..
> ..
> End Select
>
> DoCmd.OpenForm stDocName, , , stLinkCriteria
>
> I want to:
> 1) Specify a control on the appropriate form
> Preferrably by storing its name in a variable, just like I have
> stored the form name above.
> 2) Open the form
> 3) set the value of the control after opening the form.
>
> How can I do that?
>
> Thanks
>
> Abraham
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ms_access/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/