JannetteChristie
Board Regular
- Joined
- Dec 14, 2015
- Messages
- 130
- Office Version
- 365
Hi,
I am getting the following error message and am not sure how to get rid of this.
'Run-time error - 2147467259 (80004005): Method 'CopyFromRecordset' of object range failed.
The VB code is as follows:
Sub GetDataFromSql()
Dim conn As New ADODB.Connection
Dim rs As ADODB.Recordset
Dim StrCon As String
Dim StrSQl As String
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
StrCon = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=Reporting;Data Source=dpsql01"
conn.Open StrCon
StrInputName = ActiveSheet.Range("UserNameId")
StrInput1 = Format(ActiveSheet.Range("DateofRecord"), "yyyy-mm-dd")
StrInputDate = "'" & StrInput1 & "'"
StrSQl = StrSQl & "Select isnull(EQFU,0),isnull(QFU,0),isnull(TQFU1,0),isnull(TQFU2,0),isnull(CO,0),isnull(TELES,0),isnull(MEETING,0),"
StrSQl = StrSQl & "isnull(DEMOVAN,0) , isnull(SPEC,0), isnull(AMEND,0), isnull(QUOTES,0), isnull(INBOX,0), isnull(PRICESUPP,0), ISNULL(Arrange,0),"
StrSQl = StrSQl & "isnull(CPD,0),isnull(BONUS,0),isnull(SDQ,0),isnull(TWENTY4HQ,0),isnull(OTHER,0),'',GFI,START_TIME,Convert(Varchar(10),DATE,103),0,Individual_Ommph_ID "
StrSQl = StrSQl & "from Individual_Oomph where User_Name = " & StrInputName
StrSQl = StrSQl & " and Date=" & StrInputDate
Set rs = conn.Execute(StrSQl)
Sheets("Report").Range("B6").CopyFromRecordset rs
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
End Sub
I am getting the following error message and am not sure how to get rid of this.
'Run-time error - 2147467259 (80004005): Method 'CopyFromRecordset' of object range failed.
The VB code is as follows:
Sub GetDataFromSql()
Dim conn As New ADODB.Connection
Dim rs As ADODB.Recordset
Dim StrCon As String
Dim StrSQl As String
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
StrCon = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=Reporting;Data Source=dpsql01"
conn.Open StrCon
StrInputName = ActiveSheet.Range("UserNameId")
StrInput1 = Format(ActiveSheet.Range("DateofRecord"), "yyyy-mm-dd")
StrInputDate = "'" & StrInput1 & "'"
StrSQl = StrSQl & "Select isnull(EQFU,0),isnull(QFU,0),isnull(TQFU1,0),isnull(TQFU2,0),isnull(CO,0),isnull(TELES,0),isnull(MEETING,0),"
StrSQl = StrSQl & "isnull(DEMOVAN,0) , isnull(SPEC,0), isnull(AMEND,0), isnull(QUOTES,0), isnull(INBOX,0), isnull(PRICESUPP,0), ISNULL(Arrange,0),"
StrSQl = StrSQl & "isnull(CPD,0),isnull(BONUS,0),isnull(SDQ,0),isnull(TWENTY4HQ,0),isnull(OTHER,0),'',GFI,START_TIME,Convert(Varchar(10),DATE,103),0,Individual_Ommph_ID "
StrSQl = StrSQl & "from Individual_Oomph where User_Name = " & StrInputName
StrSQl = StrSQl & " and Date=" & StrInputDate
Set rs = conn.Execute(StrSQl)
Sheets("Report").Range("B6").CopyFromRecordset rs
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
End Sub