Hi guys
I am getting the above error when executing my code, can anyone spot anything obvious?
Basically I am opening a worksheet control in a userform in vba and trying to paste the database results to it.
getName is a function which returns the excel user.
Cheers
I am getting the above error when executing my code, can anyone spot anything obvious?
Code:
Dim conn As ADODB.Connection Dim rs As ADODB.Recordset
Dim sConnString As String
userid = GetName(2)
sConnString = "Provider=SQLOLEDB;REMOVEDREST"
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.Open sConnString
Set rs = conn.Execute("SELECT polNumber FROM WOFT_tbl_clients WHERE staffName = '" & userid & "';")
If Not rs.EOF Then
rs.MoveFirst
Do Until rsData.EOF
Set casesheet.Columns(1) = rs![polNumber]
rs.MoveNext
Loop
rs.Close
Else
MsgBox "Error: No records returned.", vbCritical
End If
If CBool(conn.State And adStateOpen) Then conn.Close
Set conn = Nothing
Set rs = Nothing
End Sub
Basically I am opening a worksheet control in a userform in vba and trying to paste the database results to it.
getName is a function which returns the excel user.
Cheers