Im using a connection string to connect in my MySQL Server, I was wondering how I could open the connection when the form open the use thos connection in different command/button...
lets say I have this in my OpenForm:
Private Sub Form_Open(Cancel As Integer)
Dim MyConn As ADODB.Connection
Dim sqlstr As String
Set MyConn = New ADODB.Connection
Dim MyRecSet As ADODB.Recordset
With MyConn
.Open ConnectString() // this call my string connection with information of the server...
End With
If MyConn.State = adStateOpen Then
msgbox "got connected."
Else
MsgBox "connection not established, Please try again", vbCritical, "ALIMS System"
End If
Exit Sub
==== now how could I use this connection in a click event? because the connection is open, the way I have here I placed the same call connection in all the events, I don't think it's right once they are in the same form.
Thanks in advance...