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!

Copy or pass an instance of a class mod from form to form

Status
Not open for further replies.

Jimreaper

MIS
May 22, 2001
21
US
Does anyone know the best way to copy or pass an instance of a class mod from form to form.

Ex.

frmLogin has an instance of class ClsUser called objClsCurrentUser

A cmdOk within frmLogin shows frmMain.
I would like to use or set the instance objClsCurrentUser and its current properties within frmMain.


Thanks for your help.
Newbie




 
You need to create a public variable of type ClsUser in frmMain's declaration section.
___
Public varClsUser As ClsUser 'Code in frmMain
___

Now in cmdOK's click event, you need to initialize this public variable before showing frmMain. Something like this...
___
Private Sub cmdOK_Click()
...
'Initialize the variable
Set frmMain.varClsUser = objClsCurrentUser
'Now show the form frmMain...
...
End Sub
___

After that the variable varClsUser in frmMain will hold the reference to the class instance objClsCurrentUser in frmLogin and you can manipulate this object from within frmMain.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top