Results og several queries in the same spreadsheet

J

Jo Gjessing

Hi folks,

In a database of mine I have created several simple queries. Also I have
made buttons which my users can use to start the queries and export the
results to Excel spreadsheets. It works fine except that if you click one
button and then another one the results of both queries appear in the same
spreadsheet. I want only the result of the last query to appear. Therefore
I've tried to insert a shell command which delete any spreadsheets before a
new one is created. Here is my code:

Private Sub Dialogboks_1_Click()
Dim strKommando As String
strKommando = "command.com /c del c:\temp\Ansattekartotek.xls"
Shell (strKommando)

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "spøAktør -
Enkel liste - Alle", "c:\temp\Ansattekartotek.xls"

Shell "excel.exe c:\temp\Ansattekartotek.xls", vbMaximizedFocus
End Sub

Can you please tell me why the del command does not work? Or can you give me
another way to write this so that only the result of the last query to appear
in the spreadsheet. Thank you very much in advance.

Jo
 
J

Jo Gjessing

Hi folks,

Brendan Reynolds gave me a solution so you do not need to answer my question
here. Thank you all.

Jo


Jo Gjessing skrev:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top