Vigneshrs87
New Member
- Joined
- Apr 19, 2011
- Messages
- 12
Hi,
I need some help on the DoCmd.transferspreadsheet command, Im currently using the below code.
Sub Update()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim obj As Object
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set obj = CreateObject("access.application")
cn.Open "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=C:\Documents and Settings\220409\My Documents\Database21.accdb;"
rs.Open "select count('ID') from Hi", cn
a = rs.Fields(0).Value
obj.docmd.TransferSpreadsheet Transfertype:=aclink, Spreadsheettype:=9, TableName:="Hi1", Filename:="D:\220409\Defect Tracking sheet\book1.xls", HasFieldNames:=True, Range:=MyRange
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub
Please letme know what am i doing wrong, I get an error saying that "The command ot action 'Docmd.Transferspreadsheet' isnt available now.
Thanks for your help.
I need some help on the DoCmd.transferspreadsheet command, Im currently using the below code.
Sub Update()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim obj As Object
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set obj = CreateObject("access.application")
cn.Open "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=C:\Documents and Settings\220409\My Documents\Database21.accdb;"
rs.Open "select count('ID') from Hi", cn
a = rs.Fields(0).Value
obj.docmd.TransferSpreadsheet Transfertype:=aclink, Spreadsheettype:=9, TableName:="Hi1", Filename:="D:\220409\Defect Tracking sheet\book1.xls", HasFieldNames:=True, Range:=MyRange
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub
Please letme know what am i doing wrong, I get an error saying that "The command ot action 'Docmd.Transferspreadsheet' isnt available now.
Thanks for your help.