Below is some code I'm working on. Feel free to criticise, its welcome.
Im getting an error message when I try to open the file it creates (It does create the file, the file looks fine untill opened.). The path is correct, I have changed the path in the code just because of it being on here.
I've tried:
*compact repair
*changing the spredsheet "type" to different values.
*removing variables from the file name created (you can see its commented out).
This code worked once, but not properly. It created two sheets inside the document. Both with the correct headings but only one with the data. Since this once I keep getting this error.
I have this working fine through the macros, but I have converted to VBA so I can do a check if there is any data to export.
Any Ideas what i can try?
Andy
Code:Private Sub Command18_Click() DoCmd.SetWarnings False Dim dbs As DAO.Database Dim rstSAGE As DAO.Recordset Set dbs = CurrentDb Set rstSAGE = dbs.OpenRecordset("sageimport3") myQueryName = "sageimport3" myExportFileName = "SERVER LOCATION " & "PO" & ".xlsx" '& Trim(Format(Date, "yyyy_mm_dd")) & "PO" & ".xlsx" If Not rstSAGE.EOF Then DoCmd.TransferSpreadsheet acExport, 10, myQueryName, myExportFileName, True MsgBox "Winner Winner Chicken Dinner. Your Sage report has been created." Else MsgBox "There are no records to import to sage." End If DoCmd.SetWarnings True End Sub