Exporting a Query to a Spreadsheet
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: Exporting a Query to a Spreadsheet
Thank you Hans, here's the link to Stat.zip which contains both the Excel file and the mdb
-
- Administrator
- Posts: 78630
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Exporting a Query to a Spreadsheet
Thanks, but that won't work because the query refers to linked tables.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: Exporting a Query to a Spreadsheet
The content of the qtxx query gets correctly transferred to the qt sheet in Stat.xlsx. The problem is that, only with Access 2013, the ProdvsBDG-mese sheet displays the correct values only upon recalculation.
-
- Administrator
- Posts: 78630
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Exporting a Query to a Spreadsheet
The code that I posted earlier correctly updates the values on the ProdvsBDG-mese sheet for me. I cannot test the complete code since the data in your database reside in SQL Server, not in the database itself.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: Exporting a Query to a Spreadsheet
Right-clicking a linked table in Access 2013 gives you the handy(new to me at least) command Convert to Local Table so I did that but I don't understand why, when you close the database and reopen it, the tables are back to being linked so I tried to do the usual copy and paste of the tables without success so I solved it by converting the mdb to accdb and then using Convert to Local Table. Here's the complete database and the behaviour I get is the same even with local tables.
-
- Administrator
- Posts: 78630
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Default Browser
I still get this.
Please provide a WORKING database.
Please provide a WORKING database.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: Exporting a Query to a Spreadsheet
Don't know why you get that message since there aren't linked tables anymore but in any case it should clear once you selec ODBC Origin from the Control Panel and add Italgen Project as depicted here
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78630
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Exporting a Query to a Spreadsheet
There are no linked tables anymore, but the database still contains pass-through queries, and the query that you export, qtx, depends on those...
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: Exporting a Query to a Spreadsheet
It doesn't seem to be straightforward to revert pass-throughs to normal select queries but I'll try to do it.
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: Exporting a Query to a Spreadsheet
Here's the accdb with the converted query, just press the Previous Month button on the startup form; you'll see(if you're using Access 2013) that the ProdvsBDG-mese sheet in Stat.xlsx is still beset by the same problem.
-
- Administrator
- Posts: 78630
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Exporting a Query to a Spreadsheet
Thanks. I downloaded the new database and changed the path to stat.xlsx in the code. I used the workbook from the zip file that you made available earlier this week.
Before clicking the button, column A of the ProdvsBDG-mese contained incorrect dates. But when I click the button, I get the correct result:
Using Office 2013, fully updated.
Before clicking the button, column A of the ProdvsBDG-mese contained incorrect dates. But when I click the button, I get the correct result:
Using Office 2013, fully updated.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: Exporting a Query to a Spreadsheet
Where do you see the build in Access 2013? I'd like to see if it matches yours.
-
- Administrator
- Posts: 78630
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Exporting a Query to a Spreadsheet
By the way, the On Click event procedure of the command button does not contain the code that I suggested. Try changing the line
to
Code: Select all
xlBook.Sheets("ProdvsBDG-mese").Select
Code: Select all
Set xlSheet = xlBook.Sheets("ProdvsBDG-mese")
xlSheet.Select
Dim cel As Range
For Each cel In xlSheet.UsedRange.SpecialCells(xlCellTypeFormulas)
cel.Formula = cel.Formula
Next cel
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 78630
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Exporting a Query to a Spreadsheet
To see the build of Access 2013, select File > Account.
Click "About Access" on the right hand side.
The build is shpwn in the "About Microsoft Access" dialog:
Click "About Access" on the right hand side.
The build is shpwn in the "About Microsoft Access" dialog:
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: Exporting a Query to a Spreadsheet
And once again your last piece of code saved the day
Thank you so much Hans
Does your version produce the correct results even without the added code that recalculates the ProdvsBDG-mese sheet?
Thank you so much Hans
Does your version produce the correct results even without the added code that recalculates the ProdvsBDG-mese sheet?
-
- Administrator
- Posts: 78630
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Exporting a Query to a Spreadsheet
Yes, the screenshot that I posted was produced without adding the extra code.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: Exporting a Query to a Spreadsheet
Then I guess it's a build issue. Here's mine, what's yours?
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78630
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: Exporting a Query to a Spreadsheet
Oopsie, missed that one
While waiting to upgrade, I've tried to solve it by converting RTEPSpecial.mdb to accdb format but when I open the accdb, code stops at
Set rs = db.OpenRecordset("tblReconnectODBC", dbOpenSnapshot)
in Function fReconnectODBC() As Boolean
with Error #13: Type Mismatch
fReconnectODBC is run in the AutoExec macro, I deleted the macro from the RTEPSpecial - Copia (2).accdb file I put on OneDrive since there were no more linked tables.
While waiting to upgrade, I've tried to solve it by converting RTEPSpecial.mdb to accdb format but when I open the accdb, code stops at
Set rs = db.OpenRecordset("tblReconnectODBC", dbOpenSnapshot)
in Function fReconnectODBC() As Boolean
with Error #13: Type Mismatch
fReconnectODBC is run in the AutoExec macro, I deleted the macro from the RTEPSpecial - Copia (2).accdb file I put on OneDrive since there were no more linked tables.
-
- Administrator
- Posts: 78630
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Exporting a Query to a Spreadsheet
The order of the references in Tools > References... changed, and now the ADO reference is listed above the DAO reference. So the line
Dim ..., rs As Recordset
declares rs as an ADO recordset. To avoid this problem, use
Dim ..., rs As DAO.Recordset
You should always declare a recordset explicitly as DAO.Recordset or as ADODB.Recordset, depending on which one you want to use. This avoids any possible confusion over the data type.
Dim ..., rs As Recordset
declares rs as an ADO recordset. To avoid this problem, use
Dim ..., rs As DAO.Recordset
You should always declare a recordset explicitly as DAO.Recordset or as ADODB.Recordset, depending on which one you want to use. This avoids any possible confusion over the data type.
Best wishes,
Hans
Hans