tatendatiffany
Board Regular
- Joined
- Mar 27, 2011
- Messages
- 103
i am getting this error on the line highlighted in bold any ideas why:
Code:
Sub getresults()
Dim r As Integer 'row counter
Dim c As Integer 'column counter
Dim str As String 'SQL string holder
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
With cn
.ConnectionString = "Password=" & password & ";Persist Security Info=True;User ID=" & username & ";Data Source=" & DatabaseEnv & ";Mode=ReadWrite;" 'Assumption based on your connection string being valid
.Provider = "IBMDADB2.DB2COPY1" 'assumption based on your provider being correct
.Open 'if the above are true then this will open DB
End With
For c = 31 To 35 'columns AE to AI
For r = 2 To 39 'start with first row
If Cells(r, c).Value <> "" Then 'is there a value in the row?
str = Cells(r, c).Value 'this is the SQL string we need for the recordset
Cells(r, c - 5).Value = [B]getrecordset[/B](str) 'use a function to open the recordset and return the value to column 3
End If
Next r
Next c 'next column
End Sub