Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set control value

Status
Not open for further replies.

Umbane

IS-IT--Management
Jul 20, 2000
44
0
0
ZA
This is possibly a very simple thing I am trying to do, but for the life of me I can't seem to get it right. I am trying to set the name of a control in vba and then set it's value to a stored value.

Method 1 (Which Works)
eg.
Dim MyCtl as Control
Dim MyFrm as Form
Set MyFrm = "frmABC"
Set MyCtl = Forms!frmABC.fieldname

Method 2 (Won't work)
eg.
Dim MyCtl as Control
Dim MyFrm as Form
Dim anyFrm
anyFrm = "frmABC"
Set MyFrm = anyFrm
Set MyCtl = MyFrm.fieldname

Both setting MyFrm and MyCtl produce the same error,Error 424, Object required.

Thanks in advance
 
A form is an object. But you are only supplying a string

Set MyFrm = "frmABC"
either
Set MyFrm = forms("frmAbc")
Set MyFrm = forms![frmAbc]
Set MyFrm = form_frmAbc

 
and just to emphasize MajP's point, you declared any form
as a string...

Set MyForm(anyForm)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top