VisualBasic and Access

AtlantaBob

Golden Member
Jun 16, 2004
1,034
0
0
Thanks to all who helped with my earlier SQL question. Here's another one in Access for the brilliant folks who know these things. This seems self-evident, but I might have missed something.

Image a situation where a comand button on one form (Form1) updates information on another form (Form2). Form2 may or may not already be open. It would seem that it would be inefficient to call DoCmd.OpenForm... if the form is already open.

I know that I can test to see if the form is already open and if it is set focus to it (otherwise, go ahead and open the form) with this code:

If CurrentProject.AllForms("Form2").IsLoaded Then
Forms!Form2.SetFocus
Else
DoCmd.OpenForm "Form2"
End If

I expect that I'll be using this type of stuff a lot if it actually is more efficient. Would it make sense in your opinion to create a subroutine that I can call to do this?

Thanks, everyone!