Hi, I got a runtime error 3709. It says "The connection cannot be used to perform this operation. It is either closed or invalid in this context." I can't find what's causing the error.. Here is my code:

Public Sub S_LOAD_flxUser()
Dim strSql As String
Dim rsLoad As New ADODB.Recordset
Dim a As Integer

With flxUser

.Clear
.Rows = 24
.Cols = 6
.ColWidth(0) = 300

.ColWidth(1) = 1000: .TextMatrix(0, 1) = "User ID"
.ColWidth(2) = 2000: .TextMatrix(0, 2) = "User Type"
.ColWidth(3) = 2000: .TextMatrix(0, 3) = "Username"
.ColWidth(4) = 2000: .TextMatrix(0, 4) = "Password"
.ColWidth(5) = 4000: .TextMatrix(0, 5) = "Name"

End With

a = 1

strSql = "Select * from user_tab order by UserID"

With rsLoad
.Open strSql, conn

Do While .EOF = False
flxUser.TextMatrix(a, 1) = !UserID
flxUser.TextMatrix(a, 2) = !UserType
flxUser.TextMatrix(a, 3) = !Username
flxUser.TextMatrix(a, 4) = !Password
flxUser.TextMatrix(a, 5) = !UserType
flxUser.TextMatrix(a, 2) = !UserFName

.MoveNext

If .EOF = False Then
flxUser.Rows = flxUser.Rows + 1
a = a + 1
End If

Loop

.Close
End With

End Sub

When I click debug, it highlights the ".open strSql, conn"

Thanks.. I already declared a connection object in a module. The cause of the error is that I forgot to call the sub procedure which holds the connection object in form load.. again. thanks... :)

This question has already been answered. Start a new discussion instead.