Export Data From Access Via Userform

  • Hi All,

    I have to copy data from Access tables to excel using vba. I have a userform in access and based on the selection by the user the data will be queried and has to be exported to excel. Can anybody please help? I tried using the DoCmd.OutputTo Command but that transports the result to one workbook and I have to query separate recorsets from 10 tables. So the DoCmd.OutputTo will open up 10 workbooks and I have to get all the data into one workbook. I think I should be using the recordset function but just dont know how to proceed. Can anybody please hlep?


  • Re: Export Data From Access Via Userform

    Hi Thanks for the help.

    I tried using it in the following manner:

    DoCmd.TransferSpreadsheet acExport, , , "strSQL", "the path to my file", True, "A1",

    where strSQL is the query that I am using to retrive the records. But there is an error saying that one of the arguments i entered in the DoCmd.Tranfer command is of the wroing data type. Can you please help further. Also I was wondering if there is any other way of doing this like using the recordset function. I am not very aware about how I can go ahead in both the scenarios would appreciate your help.