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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference form from another form's module 1

Status
Not open for further replies.

FabricMan

Technical User
Dec 29, 2009
7
US
I've been using Access forms as menus in a small app I'm developing. My main menu has a couple of text boxes (locked) to display certain statistics, and I want to be able to change their values from outside the module (i.e. a submenu/different form).

Me works fine if I'm within the main menu form's module, but in different modules, what are my options?

It seems these might work:

Code:
Forms!frmMainMenu!txtStat1.Requery

Dim MyForm As Form_frmMainMenu
MyForm.txtStat1.Requery

Dim MyForm As Form
Set MyForm = Forms!frmMainMenu
MyForm.txtStat1.Requery

Form_frmMainMenu.txtStat1.Requery

Which version do you think offers the best performance?
 
There are seven fora dedicated to Access on this site, I'd say this question could be posted in either forum702 or forum705, I think.

I think the consensus is to use this version

[tt]Dim MyForm As Form
Set MyForm = Forms!frmMainMenu[/tt]

at least if you're going to refer to/manipulate more than one control/property/method/object on the form.

[tt]With MyForm
.DoThisAndThat
End With[/tt]

It might also be the fastest.

[tt]Forms!frmMainMenu!txtStat1.Requery[/tt] is OK if you onoy refer to one control/property/method/object

The last one is mostly used if you need multiple instances of the same form AND you might find it a bit quirky as it might instantiate an unopened forms...

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top