I am currently working on a VB/SQL/Access project that I am creating using object oriented design. One of the problems I'm running into is how to deal with displaying a form attached to an object.
I created a class module named clsQuote. Within the definition of clsQuote I added a Public Sub-Routine called Display(). Basically I want the Display method to immediately open up a form that shows the current state of all the attributes of my Quote object.
I created a test form called frmTest which has a single button that has a single line of code attached to it's On_Click event: 'oQuote.Display'. So to make this possible I declared an object of clsQuote named oQuote and placed it inside frmTest. To be sure oQuote refers to an active Quote I added some code to frmTest On_Load event that is basically: Set oQuote = New clsQuote. Now when frmTest is loaded it will go ahead an instantiate a clsQuote object and refer to it as oQuote.
Now in the definition of clsQuote I made a Display() method that basically is: 'DoCmd.OpenForm "frmQuoteDisplay"' This would be the name of the form that is designed to show the object's current state. Here is my problem, how in the world do I populate the form because once I do the DoCmd.OpenForm code moves to this new form which does not know what oQuote is referring to. How could I pass this object refrence on to the new form using the DoCmd.OpenForm method?
I created a class module named clsQuote. Within the definition of clsQuote I added a Public Sub-Routine called Display(). Basically I want the Display method to immediately open up a form that shows the current state of all the attributes of my Quote object.
I created a test form called frmTest which has a single button that has a single line of code attached to it's On_Click event: 'oQuote.Display'. So to make this possible I declared an object of clsQuote named oQuote and placed it inside frmTest. To be sure oQuote refers to an active Quote I added some code to frmTest On_Load event that is basically: Set oQuote = New clsQuote. Now when frmTest is loaded it will go ahead an instantiate a clsQuote object and refer to it as oQuote.
Now in the definition of clsQuote I made a Display() method that basically is: 'DoCmd.OpenForm "frmQuoteDisplay"' This would be the name of the form that is designed to show the object's current state. Here is my problem, how in the world do I populate the form because once I do the DoCmd.OpenForm code moves to this new form which does not know what oQuote is referring to. How could I pass this object refrence on to the new form using the DoCmd.OpenForm method?