benjamin.grimm
Registered User.
- Local time
- Today, 04:11
- Joined
- Sep 3, 2013
- Messages
- 125
Hello
i have a query, which looks like that:
Query
ID Year SAP Geris
1 2008 20,00 € 5,00 €
1 2009 40,00 € 4,00 €
1 2010 60,00 € 6,00 €
2 2007 80,00 € 4,00 €
2 2008 100,00 € 8,00 €
2 2009 100,00 € 4,00 €
3 2008 1.000,00 € 1,00 €
3 2009 100,00 € 8,00 €
3 2010 2,00 € 9,00 €
4 2008 9,00 € 10,00€
So each combination has an ID. It´s called the SuWID.
I want to Transfer the data to a fixed Excel sheet. I wrote the following code
Dim xlApp As Object ' Excel.Application
Dim xlBook As Object ' Excel.Workbook
Dim xlSheet As Object ' Excel.Worksheet
Dim rst As DAO.Recordset
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Open("C:\Users\GRIMBEN\Desktop\Mappe1.xlsx")
Set xlSheet = xlBook.sheets("Tabelle1")
Set rst = CurrentDb.OpenRecordset("abfrage1")
xlSheet.Range("A1").CopyFromRecordset rst
rst.Close
Set rst = Nothing
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
The only Thing what i still want to have is that, before it opens the Excel form, which works allready perfectly well, that a msgbox will Show up and ask me, which SuWID do you want to see in the Excel sheet.
It that possible?
i have a query, which looks like that:
Query
ID Year SAP Geris
1 2008 20,00 € 5,00 €
1 2009 40,00 € 4,00 €
1 2010 60,00 € 6,00 €
2 2007 80,00 € 4,00 €
2 2008 100,00 € 8,00 €
2 2009 100,00 € 4,00 €
3 2008 1.000,00 € 1,00 €
3 2009 100,00 € 8,00 €
3 2010 2,00 € 9,00 €
4 2008 9,00 € 10,00€
So each combination has an ID. It´s called the SuWID.
I want to Transfer the data to a fixed Excel sheet. I wrote the following code
Dim xlApp As Object ' Excel.Application
Dim xlBook As Object ' Excel.Workbook
Dim xlSheet As Object ' Excel.Worksheet
Dim rst As DAO.Recordset
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Open("C:\Users\GRIMBEN\Desktop\Mappe1.xlsx")
Set xlSheet = xlBook.sheets("Tabelle1")
Set rst = CurrentDb.OpenRecordset("abfrage1")
xlSheet.Range("A1").CopyFromRecordset rst
rst.Close
Set rst = Nothing
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
The only Thing what i still want to have is that, before it opens the Excel form, which works allready perfectly well, that a msgbox will Show up and ask me, which SuWID do you want to see in the Excel sheet.
It that possible?
Last edited: