Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!



mjqamjqa Member Posts: 1
Hi everybody, I'm doing a simple form with a 3-table DB in access, . I'm trying to connect but I'm gettin this message: "the connection cannot be used to perform this operation. It's either closed or invalid in this context". this is the code I have
Private Sub lst_sport_DblClick(Cancel As Integer)
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

'Use the ADO connection that Access uses
Set cn = New ADODB.Connection

'Create an instance of the ADO Recordset class, and
'set its properties
Set rs = New ADODB.Recordset
With rs
Set .ActiveConnection = cn
.Source = "SELECT * from sports"
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
End With
End sub
Can u please tell me what am I doing wrong???
THanks in advanced
Sign In or Register to comment.