Hello folks !
I have a form which may have several instances
I have found all necessary explanations on Internet how to do that and it works (basic explanations at the end of this post)
On the form I have buttons that enable going to previous or next record. I need these because for each record I have related data displayed on a treeview on the form and I have code to update the treeview.
These buttons basically do this :
Now here is what happens :
I open a first instance of the form : Form1
I open a second instance of the form : Form2
on Form2 I click on the button to go to next record, and it is Form1 that moves to its next record.
I have tried putting this before the Docmd instruction :
This does not solve the issue.
The problem with Docmd is that it takes the form name as parameter, and all instances of the form have the same name (I have tried setting a specific name for each instance, but it is a read only property. Hard luck !)
Do you have any idea what can be done ?
Thank you !
Jean-Marie
PS How I create my forms : This is the code inside a specific class module (I have declared a global variable of that class) :
I have a form which may have several instances
I have found all necessary explanations on Internet how to do that and it works (basic explanations at the end of this post)
On the form I have buttons that enable going to previous or next record. I need these because for each record I have related data displayed on a treeview on the form and I have code to update the treeview.
These buttons basically do this :
Code:
Docmd.GoToRecord acForm, Me.Name
I open a first instance of the form : Form1
I open a second instance of the form : Form2
on Form2 I click on the button to go to next record, and it is Form1 that moves to its next record.
I have tried putting this before the Docmd instruction :
Code:
Me.SetFocus
The problem with Docmd is that it takes the form name as parameter, and all instances of the form have the same name (I have tried setting a specific name for each instance, but it is a read only property. Hard luck !)
Do you have any idea what can be done ?
Thank you !
Jean-Marie
PS How I create my forms : This is the code inside a specific class module (I have declared a global variable of that class) :
Code:
Set objForm = New My_Form
MyFormsCollection.add Cstr(objForm.HWND), objForm
(Adding the objForm to a remanent collection keeps the form alive)