Results og several queries in the same spreadsheet

  • Thread starter Thread starter Jo Gjessing
  • Start date Start date
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
 
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:
 
Back
Top