This is my first day with VBA. I am trying to export a .csv file in MS Access using MySQL query in VBA. I have tried using this code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sql As String
Set db = CurrentDb
sql = "SELECT wo_id FROM WorkOrder"
Set rs = db.OpenRecordset(sql)
DoCmd.TransferText acExportDelim, , "rs", "C:\export.csv", True
rs.Close
Set rs = Nothing
which gives me:
Run time error '3011':
The Microsoft Office Access database engine could not find the object 'rs'. Make sure the object exists and that you spell its name and path name correctly
MORE INFO
I have a MySQL table called WorkOrder (I would like to pull data from here).
What am I missing?