INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Reference form from another form's module

Reference form from another form's module

(OP)
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?

RE: Reference form from another form's module

There are seven fora dedicated to Access on this site, I'd say this question could be posted in either forum702: Microsoft: Access Forms or forum705: Microsoft: Access Modules (VBA Coding), I think.

I think the consensus is to use this version

Dim MyForm As Form
Set MyForm = Forms!frmMainMenu


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

With MyForm
    .DoThisAndThat
End With


It might also be the fastest.

Forms!frmMainMenu!txtStat1.Requery 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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close