0

I got a runtime error 3705 "Operation is not allowed when the object is open". When I click debug, it highlights the connection object I made in the module. I have a form named frmUser. When I click mnu_User from the mdiForm, I got a runtime error 3705, but when I set the frmUser as the Start-up object in the project properties, I didn't get any error.. The error only occurs when I call the frmUser from the mdiForm.

Here is the code for the connection:

Public conn As New ADODB.Connection

Public Sub S_OPEN_DB()
conn.ConnectionString = _     ' It
"Provider = msdasql.1;" & _   ' Highlights
"data source = kath_cn"       ' Here
conn.Open
End Sub

Here is the code for the frmUser:

Private Sub Form_Load()
S_OPEN_DB
S_LOAD_flxUser
End Sub

Public Sub S_LOAD_flxUser()
Dim rsLoad As 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

Set rsLoad = New ADODB.Recordset
rsLoad.Open "select * from user_tab order by UserID", conn, adOpenStatic, adLockOptimistic

With rsLoad

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) = !UserFullName
.MoveNext

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

Loop
.Close
End With
End Sub
2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by aquamarine_kath
Featured Replies
  • Hey, I already solved this.. but I have another problem.. How can I pass/combine for example, the name.. I have fields in my database: LName, FName, MName, and FullName LName, FName, and MName all have data and I want to combine those data and place it to FullName.. How can … Read More

1

Hey, I already solved this.. but I have another problem..

How can I pass/combine for example, the name..
I have fields in my database: LName, FName, MName, and FullName

LName, FName, and MName all have data and I want to combine those data and place it to FullName.. How can I do this?

I tried this code but it doesn't work.

strSql = "select LName" & ", " & "FName" & " " & "MName" & "." & "as FullName from user_tab"

Thanks in Advance..

Comments
Some kudos for solving your problem!
0
Fullname = Rs.Fields("Lname") & " " & Rs.Fields("Fname") & " " & Rs.Fields("Mname")

'if Fullname is also a database table field, change it e.g Rs.Fullname
0

You should specify what field of the table what you are trying to get the data from.

Same thing if you are trying to display data from different fields in a control like textbox or labels.

Text1.Text = Rs.Fields("Lname") & " " & Rs.Fields("Fname") & " " & Rs.Fields("Mname")

Edited by abelingaw: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.