Hiya,
got some code to get recordset from access and export to excel.
The VBA editor complains about either "User defined type not defined" about the
or if I move that and try to delclare it in a type block, it says "INVALID INSIDE TYPE BLOCK"
Can anyone help me out here?
Can someone show me the right way to do it? Do I need to reference a library to do this?
got some code to get recordset from access and export to excel.
The VBA editor complains about either "User defined type not defined" about the
Code:
Set Conn = New ADODB.Connection
Can anyone help me out here?
Code:
Sub GetStuff()
Dim objExcelApp As Excel.Application
Dim xlsExcelSheet As Excel.Worksheet
'Dim conn As New ADODB.Command
'Open Access db set ADODB Connection.
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEBD.4.0;" & _
"Data Srouce=" & strAccessDB & ";" & _
"Persist Security Info=False"
'Begin ADODB connection
conn.Open
'Select data from table/query MAIN_QUERY_LIVE
Set rs = conn.Execute( _
"SELECT * FROM MAIN_QUERY_LIVE", , _
adCmdText)
'''''''''''''SOME MORE CODE HERE TO INSERT DATA INTO EXCEL
'close the recordset & destroy variable
rs.Close
Set rs = Nothing
'close the connection & destroy variable
conn.Close
Set conn = Nothing
ErrHand:
MsgBox "An Error Occured", vbCritical, "Error Handle"
Exit Sub
End Sub
Type newType
Dim conn As New ADODB.Command 'THIS DOESN'T SEEM TO WORK EITHER
End Type
Can someone show me the right way to do it? Do I need to reference a library to do this?