ADO Connection

accessman2

Registered User.
Local time
Today, 00:17
Joined
Sep 15, 2005
Messages
335
Hi,

I want to create the ADO function. But, I don't know how to do the reference connection back.

Eg.

Private Sub cmdButton1_Click()
dim conn as ADODB.Connection
dim rs as ADODB.Recordset

if openconn(conn) = False then exit sub

set rs = conn.execute("select * from table1")

......

End Sub

Function openconn(conn As ADODB.Connection)
On Error goto Errconn
Set conn = New Connection
conn.open ".............."
.....

openconn = True
Exit function

Errconn:
openconn = False
End Function


Does anybody know how to do reference connection?
 
Just do this:
Code:
Dim rst as ADODB.Recordset

Set rst = New ADODB.Connection

rst.Open "table1", CurrentProject.Connection, adOpenDynamic, adLockingOptimistic
 
No, it connects to SQL Server. We cannot use this. I just want to create the function that it is for setting up the connection to SQL Server, and then retrieve it back to main function. Because if I have 5 functions which I need to connect to SQL Server, I want to go to connection function, and then back to the function, I want to do similar to reference by value.
 

Users who are viewing this thread

Back
Top Bottom