Create a "Module" and make the connection public, and then make a "Public Sub Main()" in the same Module
Maybe this code will help
Option Explicit
Public Conn As ADODB.Connection
Public Sub Main()
'This will open a global connection
Set Conn = New ADODB.Connection
With Conn
'Change the data source property in the following line
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\temp\data\chamber.mdb;Persist Security Info=False"
.Open
End With
End Sub
Then chnge the "project properties", "Startup Object" to "Sub Main"
this should work.
Hope this help.
>I would like to declare a common connection to Database so that
>I could use it at any part of my forms, etc.
>
>I have a MDI Form and all other forms are child of the MDI Form.
>I tried to declare a Public cnn1 As ADODB.Connection at the
>MDI Load form portion and also tried at the Sub Main() there.
>
>But I still get the error message saying that trying to open
>a close connection. Any suggestions?
<><><><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><><><>