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
Sharepoint - How to view version history of all items in a list on a single page
Unable to connect to Team Foundation Server
Error 607
FRSDiag ERROR_ACCESS_DENIED and EPT_S_NOT_REGISTERED
Insert Values
Need to allow a hyphens ("-") for user names in text field
how to grant permission to db_owner to restore the backup database file in sql server
Find out all used objects?
The SQL service failed to start on Windows 2003 Server
Server 2008 Workgroup question