So we have a simple query where we we can format the column of 8 digit numbers for the CRN value that works fine, but if place the numbers in an excel sheet and try to get a looping query in VBA to run on them we get no result.
What am I doing wrong or missing?
Dim DB_CONNECTION As ADODB.Connection
Dim DB_RECORDSET As ADODB.Recordset
Dim CELLADDRESS As Variant
Dim CRN As Variant
Dim ANSWER As String
Dim SQL_STRING As String
Set DB_CONNECTION = New ADODB.Connection
Set DB_RECORDSET = New ADODB.Recordset
DB_CONNECTION.ConnectionString = "Driver={Oracle in OraClient18Home1_32bit}; Dbq=XXXXXX; Uid=XXXXX; Pwd=XXXXXX;QTO=F;"
DB_CONNECTION.Open
Sheets("Data").Activate
Range("A6").Select
Do Until IsEmpty(ActiveCell)
CELLADDRESS = ActiveCell.Address
CRN = ActiveCell.Value
SQL_STRING = ""
SQL_STRING = SQL_STRING + " SELECT CUSTIMA.BCUSTCLS.U##CLASS_CODEC"
SQL_STRING = SQL_STRING + " FROM CUSTIMA.BCUSTCLS"
SQL_STRING = SQL_STRING + " WHERE CUSTIMA.BCUSTCLS.U##CUST_REF = 'CRN'"
SQL_STRING = SQL_STRING + " AND CUSTIMA.BCUSTCLS.U##CLASS_CODEC = 'DO' "
DB_RECORDSET.Open SQL_STRING, DB_CONNECTION
Sheets("Data").Range(CELLADDRESS).Offset(0, 2).CopyFromRecordset DB_RECORDSET
DB_RECORDSET.Close
ActiveCell.Offset(1, 0).Select
Loop
End Sub