im recieving the run time error 3709: the connection cannot be used to perform this operation. It is either closed or invalid in this context.
My program consists of a MainMenu form (which is the startup form) and a Customer Form (which is linked to the database). When i first click on the main menu form to access the Customer Form everything runs fine with the database connection... though when i click to go back to the mainmenu frm and then try to go back into the Customer Form again... the database connection closes for some reason and the run time error comes up... the following code is highlighted when i debug.
mrsCustomers.Open pstCustomersSQL, gcnCoastandCountry, adOpenStatic, adLockOptimistic, adCmdText
here is the rest of my code
'**Declare a New ADODB connection object variable
Public gcnCoastandCountry As New ADODB.Connection
If Left(App.Path, 2) <> "\\" Then
'**Open the connection to the database
gcnCoastandCountry.Open "Provider = Microsoft.jet.OLEDB.4.0; Data Source = CoastandCountry.mdb"
Set gcnCoastandCountry = Nothing
here is the Code on the MainMenu form:
Private Sub cmdCustomers_Click()
here is the code on the Customer Form to go back the Main Menu form:
Private Sub cmdmainmenu_Click()
'**Close the recordset and database before exiting
Set mrsCustomers = Nothing