Question: programming the subform

SuV

New member
Local time
Tomorrow, 06:10
Joined
Mar 19, 2007
Messages
2
Hi,

I'm trying to reuse one of my form (named CPDetails) as a subform in another new form (SearchCP). My CPDetails form has lots of global variable, most of them are ADODB.Recordset.
My problem is that after the form and subform are initialized, and the form is shown on the screen, all the values in the global variables of my subform(CPDetails) are gone, e.g. all recordsets = nohting and it gives me error message that the object has not been set when I tell it to access the data.

Can anyone suggest me how to solve this problem? Thanks.
 
I need more information before I can help you. It sounds like these global variables are object variables and object variables must be set with a VBA statement. You said that most of your variables reference a recordset.

It sounds like you want your subform variables to be available in your main form. Please give more details.
 
Hi realvilla... thanks for the response

The scenario is like this, I created a form (CPDetails) for displaying the record and on that form, I also allow the user to add new record, edit and delete record. All these functions need some global variable such as booleans to check for the sequences of the buttons clicked by the user, the recordset for accessing the records and the ADO connection. That form is tested and it is working properly. Now, I want to allow the user to search for the record and use the form I created previously to display it and also allow the user to make changes on the data on the same form, so I create an interface for searching (SearchCP form) and then I add that form(CPDetails) as a subform on it.

When I run the SearchCP form, it is initialized successfully and let me key in the keyword for searching but when it run the code for searching, it tells me that the connection has not been set. Then I go to check all the global variables that have been set during the initialization, all the values are lost. The boolean flags are changed back to False, recordsets and connection changed to be "nothing".
 

Users who are viewing this thread

Back
Top Bottom