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

multiple instances of form - how to reference each instance

Status
Not open for further replies.

MontyBurns

Programmer
Oct 3, 2001
99
GB
Hi,

I know how easy it is to open another instance of the current form, but...

I have a subform on my form, which in it's OnOpen event fires some code to update a textbox on the parent form (recordcount).

How do I code so the OnOpen code in the subform knows which instance of the parent form to target? There will be the initial instance and a maximum of two other instances which are opened by separate command buttons.

The problem this is causing is that every time I click on the button to open a new instance, it opens very briefly and then disappears again straight away. I'd post some code but i'm unsure what code to post!

Any help would be really appreciated,
Burns
 
sorry, that was actually the Form_Current event which is firing on the subform, not OnOpen.

Burns
 
I seem to be (almost) answering my own question here - apologies.

I seem to have narrowed the problem down to Access 2k. Even this simple code on a fresh form with one command button works in 97, and yet doesn't work with 2k.

Private Sub Command0_Click()
Dim frmTest As New Form_frmTest

Set frmTest = New Form_frmTest
frmTest.SetFocus

End Sub

As I said above, it seems to open the form very briefly before shutting it down. Seems like it's got something to do with the way Access 2k handles each new form - i.e. it appears on the taskbar.

Any ideas on how to open multiple instances of a form in Access 2k anyone?

Thanks,
Burns
 
how embarrassing. I have answered my own question...

It was due to me declaring the form instance variable as Private (Dim-ing it) rather than Public, in a Module. Doh.

I do have a problem which is pretty much spot on to what my initial question was, but i'll do another post.

Burns
 
I've always declared these variables at the top of the form's module. That way, when you close the instance, the variable goes out of scope and gets cleaned up.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top