Microsoft
Software
Hardware
Network
Question : Use Variable to address a control
I have two subforms, each with a command button called "cmdAddNewRecord". I refer to these form the main form. Rather than having the same code to refer to each, I want to declare the form name as a vaiable and use the variable in the code
The code is:
Me.frmProfile.Form!cmdAddN
ewRecord.V
isible = True
What I would like to is:
dim FormName as string
FormName = "frmProfile"
and then change the code to:
FormName.Form!cmdAddNewRec
ord.Visibl
e = True
But Access does not like this!
What is the correct syntax?
Answer : Use Variable to address a control
You would do it like this:
Forms(FormName).Form.cmdAd
dNewRecord
.Visible = True
Note that you refer to a "main" form differently than you do a Subform.
Random Solutions
Combo box strange behavior
How to save Excel 2007 spreadsheets into a form readable by Lotus 123
IIS 7
Search for Procedure SQL Server
How can I know HTTP status code on CHTMLView?
ActiveSync sycn only working one way for Calendar, tasks and contacts, working both ways for email
Brainstorm: PDF Hyperlink into Access Form with Variable
Server 2003 Anonymous Login Event ID's
Cannot Open Volume For Direct Access in Sched CHKDSK
Error - Excel could not save all the data and formatting you recently added to myfile.xla ...