I am exporting the data from ms access to excel where the error displays as Run-time error -2147467259(8000 04005)
Method 'Copyfromrecord set' of object 'Range' faild.
Ws.Range("A2"). CopyFromRecords et rs
One of my Field Name, DATATYPE is set to MEMO
I am testing with DATATYPE As TEXT and the Characters within 255 then the report get's downloaded to Excel, if the DATATYPE is set to MEMO and the characters are more than 255 error dispalys as explained above.
.......iam using the below code
---------------------
Kindly help me....
Ananth
Method 'Copyfromrecord set' of object 'Range' faild.
Ws.Range("A2"). CopyFromRecords et rs
One of my Field Name, DATATYPE is set to MEMO
I am testing with DATATYPE As TEXT and the Characters within 255 then the report get's downloaded to Excel, if the DATATYPE is set to MEMO and the characters are more than 255 error dispalys as explained above.
.......iam using the below code
Code:
.
Dim strmsg As String
Dim DB As Database
Dim Qd As QueryDef
Dim rs As Recordset
Dim Ws As Object
Dim i As Integer
Dim FirstDate As String
Dim LastDate As String
Dim Status As String
Dim mypath As String
Dim WB As Workbook
Set DB = CurrentDb()
Set Qd = DB.QueryDefs("Database Reports Query")
Set rs = Qd.OpenRecordset()
Set WB = Workbooks.Add
Set Ws = Sheets("Sheet1")
Range("A1").Select
For i = 0 To rs.Fields.Count - 1
Ws.Cells(1, i + 1).Value = rs.Fields(i).Name
Next
Ws.Range(Ws.Cells(1, 1), Ws.Cells(1, rs.Fields.Count)).Font.Bold = True
Ws.Range("A2").CopyFromRecordset rs
Sheets("Sheet1").Select
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Columns.AutoFit
Range("A1").Select
Me.cboStartDate.Value = ""
Me.cboEndDate.Value = ""
Me.Status_Reports_up_to_date.Value = ""
strmsg = strmsg & "Report downloaded successfully...!!!"
If MsgBox(strmsg, vbOKOnly, "Reports!") = vbOK Then
End If
WB.Close
Qd.Close
rs.Close
DB.Close
Kindly help me....
Ananth
Comment