VBA - Printing Access Query Results To Excel Spreadsheet

Dec 13, 2004

So I'm having timing issues trying to print data from an Access (actually SQL Server) based query to a Excel Spreadsheet. Basically I'm trying to get around using MS-Query and last week I didn't seem to have any problem as far as performance. However, when i tried running today it seems I've had a slow down of at least 500%. The data I'm trying to print is quite large (few hundred records and about 140 fields) so I expect some performance issues. Like I said though i just can't undestand the decrease. Possibly machine performance?

Anyhow, I've tracked the bottle neck and no suprise it is in the loop, I'm just suprised it takes so long to loop through the recordset.

Here's my code, any help will be appreciated?

'Generate grid to dump data
If intRecordSetCount > 0 Then
rst.MoveFirst
'Loop through length and width and display results
Do Until rst.EOF
intRSTField = 0
intFieldCount = intField
For intIndex = 1 To intColumnCount

Worksheets(strWorksheet).Cells(intRowCount, intFieldCount).Value = rst(intRSTField)
intFieldCount = intFieldCount + 1
intRSTField = intRSTField + 1

Next intIndex
intRowCount = intRowCount + 1
rst.MoveNext
Loop
Else
MsgBox "Recordset has not been initialized or does not exit"
End If

'Define name range
ActiveWorkbook.Names.Add Name:=strRangeName, RefersTo:= _
"= '" & strWorksheet & "'!R" & intRow & "C" & intField & ":R" & intRowCount & "C" & intFieldCount, Visible:=True

View Replies


ADVERTISEMENT

Query Results On One Access/Excel Spreadsheet

May 18, 2006

I'm new to Access, but a coworker has a huge project to undertake. There are over 200 queries that produce 1 row results for each query. She's been cutting that row and pasting it into Excel 200 times. Is there an easy way to insert them 1-by-1 into Excel or prefereably Access?

BTW, the columns are the same on the query results. I'll keep investigating while I wait for the experts to answer.

View 2 Replies View Related

Queries :: Create A Query That Can Run On Weekly Basis And Save Results To Excel Spreadsheet

Feb 18, 2014

I have a database of around 15,000 users and I'd like to create a query that I can run on a weekly basis and save the results to an Excel spreadsheet. The results need to be logical and understandable by my coworkers.

Unfortunately, the actual results of the query are not (in their raw form) logical or easy to interpret.

Let's say I have a table called "users" and within that I have:

Surname
Forename
FieldA
FieldB
FieldC

FieldA has a value of either NULL or a 12-digit number
FieldB has the values are "ENABLED", "DISABLED" and "N/A"
FieldC contains a value of either "1" or NULL

This means nothing to my coworkers who want each user to be sorted into a "category". As I'm running this on a weekly basis, I'd like this query to do the work for me, so I don't have to manually assign everyone to a category in Excel. Plus, of course, there is no chance of human error if the query does this for me.

Sooo... I'd like my query to categorise for me as follows:

Category1 = FieldA IS NOT NULL and FieldB="ENABLED"
Category2 = FieldA IS NOT NULL and FieldB="N/A"
Category3 = FieldA IS NULL and FieldB="ENABLED"
Category4 = FieldA IS NULL and FieldB="N/A"
Category5 = FieldA IS NOT NULL and FieldC = 1
... etc.

I'd like the final column in the query results to simply list the category name, so I can simply copy and paste the data into an Excel spreadsheet and be done with it, safe in the knowledge that it makes sense to all.

View 14 Replies View Related

General :: Update Preformatted Excel Spreadsheet With Access 2010 Query?

Jun 10, 2013

I have an Access crosstab query that I have exported to an Excel Spreadsheet. I have the spreadsheet formatted using conditional formatting and I'd rather not have to reset it every morning. It's a single spreadsheet (the columns/rows will not deviate greatly day to day) and should be very simple, but I'm not getting it for some reason.

So if I have "Test.accdb" and it contains "qryX" as my crosstab and "Sheet1.xls" is my formatted Excel spreadsheet, how do I code for the latest "QryX" to go in and replace the old "QryX" data in "Sheet1.xls" ?

View 2 Replies View Related

Using Financial Formulas From Excel On Query Results In Access

Aug 31, 2012

I have a query that includes several columns, one of those columns shows returns on investment as a percentage. I need to figure out the annualised returns on investment using the following excel formula

{=PRODUCT(1+B1:B24)-1^(12/24)-1}

This formula gathers the percentages for the last two years then provides an annualized amount.

I'm just wondering whether this is possible to apply to the query so that when I open the query it can provide me with the 2 year annualized statistics.

View 1 Replies View Related

Reading Excel Spreadsheet From Access??

Sep 14, 2004

I am trying to connect to an excel spreadsheet and read it from access. What is the object naming scheme in excel?? I am trying to read "Sheet1" but I am getting an error. My final goal is to export a list of forms and queries list in the excel spreadsheet from one database to another. How do I know if I have "Excel 8.0"?? Here is my code:

Sub ImportForms()
Dim cnn1 As New ADODB.Connection
Dim rst1 As ADODB.Recordset
Dim strExcelPath As String

strExcelPath = "C:ModificationRequest.xls"
'Open and set recordset
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strExcelPath & ";" & _
"Extended Properties=Excel 8.0;"

Set rst1 = New ADODB.Recordset
rst1.CursorType = adOpenKeyset
rst1.LockType = adLockOptimistic
rst1.Open "Sheet1", cnn1, , , adCmdTable

'Open Recordset and print test record
Debug.Print rst1.Fields(0).Value, rst1.Fields(1).Value
'Clean up objects
rst1.Close
Set rst1 = Nothing
cnn1.Close
Set cnn1 = Nothing

End Sub

View 1 Replies View Related

Opening An Excel Spreadsheet From Access

Jan 30, 2006

I have set up a command button to export an query to Excel, then create a pivot table with the data. That all works fine however the code which opens the sheet for veiwing after the code formats the pivot table only works once. The second time the user runs the query it is in read only mode those it has been close. The code I used to open the spreadsheet is:

Dim oApp As Object

Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
On Error Resume Next

oApp.UserControl = True
Workbooks.Open Filename:="I:Program FilesCount.xls"

The users are just closing excel normally. Any Ideas?

View 1 Replies View Related

Excel Spreadsheet Linked As Access Table

Aug 23, 2005

I'm trying to link a spreadsheet as a table in Access 2002. The link wizard is importing my number columns as numbers, even though I defined them as text. I need for them to be text in Access. How do I force this?

Thanks

View 6 Replies View Related

Formating Excel Spreadsheet From Access Question

Oct 9, 2004

I need to format a worksheet in excel after I transfer data to it. I createobject("excel.application") to open an excel spreadsheet. My problem is I need to freeze the first three rows, i.e when you scroll down the spreadsheet the first 3 rows always stay in view. The only way I have seen to do this is use the windows menu form the excel application. I am creating this excel spreadsheet each time a report is run. Does anyone know how to this is VBA??

Thanks

View 2 Replies View Related

Modules & VBA :: Export From Access For Each ID To Each Spreadsheet In Excel

Sep 3, 2013

I've got a table with data about a contract. Each contract has his own ID. For each contract i have Information from SAP, Information from a System called geris and a System called pauschale. No I would like to Export that to Excel. With VBA, I would like to transfer the data for each ID to each spreadsheet.

View 6 Replies View Related

Importing Excel Spreadsheet Into Access 2010

Dec 9, 2014

I have a spreadsheet that I'd like to import into Access 2010 however prior to the import, I'd like to delete some of the rows in the spreadsheet.The spreadsheet only has one workbook.It will likely always be rows 1-10.I have already set up the Excel 14.0 Object reference, if that's even necessaryHow can I accomplish this using either VB or query?

View 2 Replies View Related

Import A Large Excel Spreadsheet Into Access

Aug 20, 2015

I'm trying to import an Excel file into access as a table so I can use the data in other tables I am building. When I try to import to file, I get an error message telling me that there are over 255 columns and not all my data will be imported. The file is a report I pull from another system at work and it is very large, is there a way to get past the 255 column limit?

View 1 Replies View Related

Transferring Spreadsheet From Excel To Access. Problem With Column Name

Nov 15, 2007

hi
i am transferring spreadsheet from Excel to Access table


pathbgc = Path & "X.xls"
DoCmd.TransferSpreadsheet acImport, , "tableX", pathbgc, vbYes


pathbgc = Path & "Y.xls"
DoCmd.TransferSpreadsheet acImport, , "tableY", pathbgc, vbYes



This works fine as long as column names in Excel do not have periods. (.)
Other then asking whoever is sending this not to put periods, is there painless way ignore that fact that excel has it, un just do it without it ?

View 7 Replies View Related

Importing Excel Spreadsheet To Access Database Daily

Jun 1, 2006

I need some help on this one. :confused: I have two Crystal Report generated Excel spreadsheets that are auto-updated on a daily basis. One spreadsheet contains computer assets, type, model, locations, etc. The second spreadsheet has users assigned to them, phone numbers, etc. I need to import these in to existing tables with numerous filters into my Access database weekly. They don’t change a whole lot but I need the changes to be reflected in my database.

The way I have it setup now is through a linked table, then I use a “Make table query” to filter the data.

My problem is the filtered table has relationships set up that I have to delete then recreate every time I need to run the “Make table query” because it has to delete the old table first.

Is there a better way to make this happen?

View 2 Replies View Related

Export Table Data Into An Excel SpreadSheet (VBA, ACCESS)

Mar 3, 2008

I have an export function below that will export my table "Test" to an Excel Spreadsheet.

However I want it so i can choose where that data in the "Test" table will go in the Excel Spreadsheet i.e. I want to export all the data in to Cell "B2" of the SpreadSheet - at the moment it will export all the data into "A1"

Any help or ideas?


Private Sub Command3_Click()

'Export function
'EXPORTS TABLE IN ACCESS DATABASE TO EXCEL
'REFERENCE TO DAO IS REQUIRED

Dim strExcelFile As String
Dim strWorksheet As String
Dim strDB As String
Dim strTable As String
Dim objDB As Database

'Change Based on your needs, or use
'as parameters to the sub
strExcelFile = "E:CSCLDMSLDMSDatabaseAppLDMS_Spec.xls"
strWorksheet = "WorkSheet1"
strDB = "E:CSCLDMSLDMSDatabaseAppLDMS_IFF_APP.mdb"
strTable = "Test"

Set objDB = OpenDatabase(strDB)

'If excel file already exists, you can delete it here
If Dir(strExcelFile) <> "" Then Kill strExcelFile

objDB.Execute _
"SELECT * INTO [Excel 8.0;DATABASE=" & strExcelFile & _
"].[" & strWorksheet & "] FROM " & "[" & strTable & "]"
objDB.Close
Set objDB = Nothing




End Sub

View 2 Replies View Related

Can Excel Spreadsheet Reference Access Table For Its Data

Mar 27, 2015

Can an Excel spreadsheet reference an Access Table for it's data? Sort of like a vlookup, but instead of referencing another spreadsheet, I'd like to pull data in from a database.

View 1 Replies View Related

Update Access Table With Daily Excel Spreadsheet

Apr 28, 2014

what I have in Access is a table which lists jobs via their HB Number (as well as a ID number access gives them). For each job there is a bunch of details and some Yes/No fields.Each day I will get a dump from another system that will list jobs like this, I then need to "Update" the Access table with any new information from the excel dump. The update would need to:

1. Insert new records (jobs) from Excel dump into Access Table
2. Update any of the records fields (except HB of course as its unique) in the access table from the Excel dump (the Excel dump obviously wont have access ID numbers, but will have the HB)For a real basic example:

Access Table Like So:

ID
HB
Finished

1
5A
Yes

2
5B
No

[code]...

the actually data has lots of different fields and many many many more records. But yeah basically need to update the table from an excel dump.I thought it was as simple as doing a Excel Import > Append Table thing in Access, but that just seems to add the new records and ignore the updated fields?

View 14 Replies View Related

Can Information In Access Update Records In Excel Spreadsheet

Mar 13, 2013

We are developing a work evaluation for all of out employees on the shop floor.

While Access is way easier to update and allow for quicker ways to gather information, our requirements is that we must display a training matrix. While access has great reporting features, it is tough to get it a format with all users listed on top, tasks listed on the LH side and knowledge levels showing what level each user is at for each task.

I am limited by standard practice on how to display it so I was curious to know if information updated in Access can be updated on an Excel spreadsheet as well. I know in Excel you can format one spreadsheet to update another but I can't figure out away to have Access do the same thing.

View 5 Replies View Related

Import Excel Spreadsheet Which Contains Command Buttons With VBA Code Into Access?

Dec 13, 2011

Is there anyway to import my excel spreadsheet which contains command buttons with vba code into access?

View 2 Replies View Related

Updating Multiple Access Records From Imported Excel Spreadsheet?

Mar 1, 2012

Access Database 2010 is used to capture progress on accounts. We are able to perform remedies on multiple accounts in the field and would like to update the records in Access all at once (by batch) rather than one-by-one.

I would like to export specific records from Access into Excel, make the updates to the records in Excel, then import the changes back into Access. I am looking for the updated Excel spreadsheet to overwrite the existing data in Access for that particular record.

View 5 Replies View Related

Queries :: Printing Query Results Using A Button

May 10, 2013

I have a form that is set to display the results of a query into a subform... How can I get those results to a printer using a button. I don't need it to print the form just all the results that are in the subform.

View 3 Replies View Related

Modules & VBA :: Exporting Query To Excel Spreadsheet

Sep 18, 2014

I am trying to export a query to an pre-existing spreadsheet. I am new to VBA and when I implement the following code nothing happened.

Option Compare Database

Public Function Sheet(strTQName As String, strSheetName As String)

Dim rst As DAO.Recordset
Dim ApXL As Object
Dim xlWBk As Object

[Code].....

View 5 Replies View Related

Queries :: How To Export A Query Result To Excel Spreadsheet

Jul 3, 2013

how to export a query result to an Excel spreadsheet, using the DoComd as this

DoCmd.OuputTo acOutputQuery, "#query_name#", acFormatXLS, "#excel_sheet_title.xls#", True.

My problem (if you can call it that) is how to append the current date to the name of the spreadsheet. E.g.,

DoCmd.OuputTo acOutputQuery, "qry_query_all", acFormatXLS, "Query_all.xls", True....

So the spreadsheet would be Query_all_03072013.xls.

View 2 Replies View Related

Reports :: Using Transfer Spreadsheet Command To Output Data In Query To Excel 2010 Format File

Aug 18, 2015

I'm working with Access 2010 and am trying to use the transferspreadsheet command to output data in a query to an Excel 2010 format file. Here is the line of code:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "q_calldetails_tmp", "c: emp estoutput.xlsx"

It works fine and produces the output file but when I try and open it with Excel I get an error saying the format is incorrect. If I change the extension to .xls it opens with no problem but I need it to be an Excel 2010 format with correct extension.

View 3 Replies View Related

Modules & VBA :: Excel Running Access - Returns No Results On 1st Go

Aug 6, 2013

I wrote some code in Excel to open and run a module in Access. The code executes, but when I check the results I get no records, however if I just step back 1 line and rerun the query, I get records. Alternately, if I run the code twice it will get results the 2nd time.

The OpenCounter opens a Session in the terminal screen then performs a macro that writes to a temporary table.

Here is the code:

Dim db As ADODB.Connection, Rst As ADODB.Recordset
Dim Acc As Access.Application
Set db = New ADODB.Connection
db.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & DBPath
Set Rst = New ADODB.Recordset

[Code] ....

One thing I tried with limited success was to tell the OpenCounter to open and close the table after it was done writing to it, but that seems like a lazy solution and it also doesn't always work.

View 1 Replies View Related

Looking For Example Of Exporting Query Results To Excel Template

Jan 27, 2008

Hi all,

I'm not very experienced with Access. I'm looking for a very simple sample of how to export Query results to an Excel Template document. Especially to specific cell references. Would anyone have one to share. I'm trying to get my head around the concept first.

I may have to use Access 2000 and later versions to run the database, so do I have to cater for both DAO and ADO?

Thanks in advance for any help
rgs
Ginny

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved