VBA: Create PivotTable From A DAO Recordset

Sep 24, 2009

I have been creating pivot tables (from the active workbook) with ADO for a while and its working great.

I just tried to switch to DAO and adapted my code accordingly but the new code fail at:

Code: ....

View 9 Replies


ADVERTISEMENT

Create Pivot Table Based On Access Recordset

Nov 1, 2008

I'm looking for an example of creating a pivot table based on an ADO Access Recordset.

I understand I can use MS Query - which I am, but looking to see if an alternative exists. A table I am inetrested in currently has 400,000 records I would like to retrieve and pivot.

View 9 Replies View Related

Create PivotTable With Two Columns Of Data For The Same Column Header?

Dec 24, 2012

Can I create a PivotTable with two columns of data for the same Column header?

I have created a PivotTable in Excel 2003 with months for rows and cities for columns. I would like to have TWO columns of data for each city. The two data columns are: Average House Selling Price, and Number of Houses Sold. When I put both of these data fields into the PivotTable Wizard, they are listed below each other so that each Month occupies two rows, but each city occupies one column. I want the two data fields beside each other so that each month only occupies one row, but there are two data columns for each City.

View 2 Replies View Related

PivotTable Code: The PivotTable Field Name Is Not Valid

Aug 3, 2007

The code I'm using that results in the following error message: "Run-Time Error '1004':

The pivotTable field name is not valid. To create a pivottable report, you must use data that is organized as a list with labeled columns. If you are changing the name of a pivottable field, you must type a new name for the field." Here's the code, I've seperated it into each sub hoping that will make it easier to read:

Option Explicit

Sub main_prog()
Call td_metrics_import
Call pt_td_metrics("Pivot_Page1", "PivotTable1", "PivotTable2")
Call pt_td_metrics("Pivot_Page2", "PivotTable3", "PivotTable4")
Call create_graph
End Sub...............

View 8 Replies View Related

How To Use Offset With Recordset

Feb 25, 2013

i have a created a connection with Access table named Test, the table has 3 fields, ID,Firstname and LastName. The values in field firstName is filled in a Combox which is in Sheet1 of excel sheet.

so far i have done with the coding which create a connection with access table and fille all the firstname from the table to the Combobox using a recordset.

the code for filling combobox value from records set is like

Do Until RecordSet.EOF
shp.ControlFormat.AddItem RecordSet.Fields("Name").Value
RecordSet.MoveNext
Loop

Now what I need is whenever I select a name in a combobox the Cell A1 in excel should show me the LastName for that name.

I am not very sure if we can use offset in this.

View 3 Replies View Related

Open The Recordset

Dec 29, 2008

i have a select statement, that pulls one row from access and i need to get the data and assign it to different fields in a userform. however, because it only pulls one row, its at .eof and closes, so any following statements cause errors because the recordset is closed.

qc.Open "SELECT * FROM [Equipment_Table] WHERE [Equipment_QC] =" & combobox12.text, cn, adOpenStatic
Equipment_Title.text = qc.fields.item("Equipment_Title")
Equip_File = qc.fields.item("Equipment_File")
Equip_ID = qc.fields.item("Equipment_ID")

View 9 Replies View Related

Delete All Entries In Recordset ADO

Jan 25, 2012

I got a recordset which I get from a database (I use ADO).

I want to delete every entry in that recordset from the database.

View 4 Replies View Related

VBA - Unable To Get Data For Recordset

Feb 28, 2014

I've Created Connectionstring for excel which is in database format and trying to get the data by comparing 2 sheets using he below code.. But not working..

Set ws = Sheet1
sSQL = ""
sSQL = "SELECT [Company Code], "

[Code].....

View 1 Replies View Related

PasteSpecial Format CSV From Recordset

Jul 28, 2008

Currently, my code involves making a connection to a db then run queries. Results from the queries goes to recordset & from the recordset copy to specified range in excel worksheet. I am trying to do an automation process.

The problem is that once the record is pasted in excel worksheet, the date column is not being recognised as date therefore excel function (vlookup) is not giving me the results in my report.

When i do a manual PasteSpecail as CSV into the worksheet from the query result, my report gets populated with data which is correct.

i've tried doing a pastespecial format:="CSV" but it doesnt work.

Is there any codes that i can use to copy from the recordset as a CSV format pastespecial??

Or any other ways that can be done?

View 9 Replies View Related

Insert Ado Recordset Into Table

Sep 23, 2009

I'm getting extremely frustrated with trying to find some code that allows me to paste an ADO recordset into a database table!

What I am doing is on a weekly basis is creating a plan of which containers my company needs to devan. We have a system that stores shipping information about these containers and I get shipping information delivered to me via e-mail from one of our major shipping companies. Their data is more accurate so what I do is paste the data I get from them into my container planning sheet and import it into out Teradata Warehouse to query against using ADO and I import this one record at a time. This is extremely slow!

In order to get around this I want to create a recordset from this data and then paste the recordset into a table in the database. So far this is my ....

View 9 Replies View Related

Pivot Table From Vba Ado Recordset

Nov 15, 2006

Is there an example outthere that will demonstrate how to create a pivot table using an ADO Recordset? I'll be experimenting tommorow but really don't relish the thought of spending 12 hours trying to figure it out.

View 2 Replies View Related

Sporadic Headers When Reading CSV Into Recordset

Nov 8, 2011

When I read a CSV file into a recordset, the headers are not all being read. I get gaps in the headers for whatever reason. Attached below is the Function to load the recordset from the file. I have hard coded Hdr to "No" in the connection string.

Code:

Function QueryByID(tableName As String, fieldToQuery As String, Target As Long, Hdr As String) As Recordset
Dim strFilePath, strFileName, strQuery As String
Dim oFSObj, oConn As Object
Dim oRs As Recordset
Dim f, lastRow As Integer

[Code] .......

The below is how I output the resultset:

Code:

Sub OutputResultSet(aTable As String)
Dim row, col, i, j As Integer
row = 1
col = 1
ThisWorkbook.Sheets(aTable).Activate

[Code] .....

I have triple checked the CSV file and the first row in each file has definitely got headers. Some headers are loaded and output fine, others are just blank.

View 5 Replies View Related

Filling Listbox With Recordset From Access

Jan 17, 2012

I want to fill a listbox with values from a database.

The query et al. works just fine, but I cant get the listbox filled.

Is there a command to fill the listbox with all the entries in the recordset at once?

View 5 Replies View Related

Current Recordset Converts In An Array

Nov 30, 2009

I have a sub-routine I call on that takes a current recordset and converts it to an Array.

I would like to make this sub-routine tool more flexable by being able to specify THE NAMES for the recordset and an array involved.

For example

Sub My_Code()

....blal bla bla.... current code...

Call Recordset_To_Array( Recordset_name, Array_name )

....bla bla bla... continued

end sub
And the subroutine tool:

Sub Recordset_To_Array( Recordset_name as String, Array_name as string )

'Code that generates RS
'Need to take Recordset_name string value and use it in the line below at "XXXXX"
Dim XXXXX as Recordset

'Code that generates array
'Need to take Array_name string value and use it in the line below at "XXXXX"
Dim XXXXX as Variant
End Sub

View 9 Replies View Related

Working With Recordset In A Range Of Cells

Oct 14, 2006

how i can display different values using the Selection.FormulaArray, ok look at my
Dim mySheet As Worksheet

' On Error GoTo errors
Dim x As Integer
x = TextBox1.Text
Dim y As Integer
y = RefEdit2.value

Set mySheet = Excel.ActiveSheet
mySheet. Range(RefEdit1).Select

Selection.FormulaArray = "=multiplie_value(""" & x & """, """ & y & """)"
MsgBox Selection.FormulaArray

Now the function i call:

Public Function multiplie_value(valor As Integer, multiplo As Integer) As Integer
multiplie_value = Val(valor) * multiplo
End Function

thats an example. so the real question is i create a form, the user enter some values to search to a database, the user select an area(a range) where they want the data to be display, but i dont how to display that info that is coming from the database in the range that the user selected. The info displayed in the range should look like a tabular report, column headers, etc.

View 9 Replies View Related

VBA Recordset Not Returning Updated Results From Query?

May 9, 2012

I have a function that loops through sheets and opens a query and copys the information to a sheet. I have gone in the access db and updated the query. Yet everytime i call it in excel it returns the old data. I have gone into access and verified what data I should get and I just don't get it.

I pass in the query name and the sheet name into qryName and sheetName name.

Code:
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sQRY As String
Dim strFilePath As String

[Code].....

View 1 Replies View Related

Return PreStored Query Result Into Recordset Through Excel

Sep 12, 2013

I am trying to run a prestored query in a Access database and popuate the result into a Recordset --- through Excel. So far, I have managed to accomplish that using the code below. However, now I need to update some records in the recordset. The code below does not allow me to do so.

The following message prompted when the code tried to update the record: Run-time error '3251' Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.

This is written for other users who only knows how to create a query in Access. And the users prefer not to import the query results to spreadsheet.

*Someone suggested use Recordset.Open however, that seems to work only with SQL statement but not prestored Queries.

Code:
Sub RunExistingQuery()
'Execute prestored queries in Access
Dim Con As ADODB.Connection

[Code].....

View 2 Replies View Related

Problem Displaying Single Record In Userform Listbox From Recordset

Jul 20, 2009

I am trying to populate a 3 column listbox in a userform from SQL Server via ADO. When the result set consists of more than one record, there is no problem and the data is displayed properly (ie each piece of data is in its appropriate column) eg...

StockCode..........QtyReqd.........JobDeliveryDate
test1...................1................. 01/01/1900
test2...................1..................31/12/1900
test3...................3..................18/02/1900

however when the recordset returns only a single record, the data does not transpose and views as below (ie each piece of data in the record is on a different line in the first column

StockCode...........QtyReqd.........JobDeliveryDate
test1
1
01/01/1900

View 12 Replies View Related

Excel 2010 :: ADO Recordset Query Quandary Locating Duplicates

Mar 13, 2013

I am having trouble setting up a query for a recordset that will list duplicates for an automated process to clean up. I am using Excel 2010 with Microsoft ActiveX Data Objects Recordset 6.0 Library and Microsoft ActiveX Data Objects 6.1 Library as references.

So far, I have chopped the query down to it's most basic elements and reassembled until it broke. Necessary pieces work well, but when I combine them, I get nowhere.

Here is the working simple query to retrieve a single row:

Code:
dupeSQL = "SELECT PSID FROM [Obstructed$] "

Here is the working single query to retrieve a count:

Code:
dupeSQL = "SELECT COUNT(PSID) As '" & "CountPSID" & "' " _
& "FROM [Obstructed$] "

When combined, I cannot figure out why it won't work:

Code:
dupeSQL = "SELECT [PSID], COUNT(PSID) As '" & "CountPSID" & "' " _
& "FROM [Obstructed$] "

Here is what I am trying to get to:

Code:
dupeSQL = "SELECT [PSID], COUNT(PSID) As '" & "CountPSID" & "' " _
& "FROM [Obstructed$] " _
& "WHERE COUNT(PSID) > 1 " _
& "GROUP BY PSID"

I can even work without the GROUP BY. I have also played with the HAVING clause to try and accommodate the [PSID] field, but have gotten nowhere.

View 1 Replies View Related

Creating A PivotTable Using VBA

Apr 30, 2014

I am unsure if this is supposed to be in the PivotTable or VB section, but given it is VB code I expect here is better.

[Code] ......

I can confirm the SourceData exists, and can be used to create a pivot table without error. Only when I try to RUN this code does it kick out saying, "Invalid procedure call or argument".

View 3 Replies View Related

Name New Sheet Used For PivotTable

Oct 8, 2007

In the macro I am writing I open a pivot table which as you know creates a sheet. I would like to name that sheet. My problem is that the default name(number if you will) changes every time I run my macro so I am unable to define which sheet I want to give a name.

View 2 Replies View Related

Possible For Count & Sum In PivotTable

May 20, 2008

Is it possible to have both SUM and COUNT values on one PivotTable?

View 3 Replies View Related

Hide PivotTable Row Labels?

Feb 4, 2014

I have a PivotTable with data and I want to hide the row labels (in blue) that's in the first row.

See image:[URL]

PivotTable.jpg

View 4 Replies View Related

Values Appear Twice In PivotTable Row Labels

Jan 31, 2010

I have a PivotTable that is summarizing a data table. In the configuration panel, I've dragged one column ("C92") to the "Row Labels" area. Likewise, I've dragged the same column to the "Values" area, where it defaults to "Count of C93". So far, so good.

I should mention that my values in column C92 are the whole numbers 0-7 and the string "NA". But in the output chart, each of these values is listed twice! And each count of each value is different! I'm attaching a cut-down version of the spreadsheet that shows this behavior.

View 2 Replies View Related

Automate Autofill For PivotTable

Dec 22, 2009

I have a document that is exported from an SQL database. Once I have the data I need to throw it into a PivotTable to analyze it. However, the export doesn't fill every cell with the information - instead displaying the cell value once until a new value comes up. Therein, there are often a number of blank cells underneath each entry.

I can overcome this by going into the document and autofilling each cell that doesn't have the information in it. However, some of the reports are very large and it is quite time consuming.

What I'm after is for a bit of VBA that will autofill the cells until it hits another new cell value then autofill this down until it hits another new cell value, etc.

I have attached a dummy copy of the report - one sheet, Raw Data, shows the data as it is exported and the other, Autofilled, shows how I would like the data to be displayed after the code is run.

View 2 Replies View Related

Adding Columns Within A Pivottable

Jun 19, 2007

I have a data worksheet, which contains about 20,000 lines of journal entry info. There is a separate column for debit and credit, not one "amount" column. On another worksheet, I am aggregating the data to review the impact for this series of journal entries over a time period (12 months). Thus, my pivottable contains "Accounts" in the "ROW" and "Period" in the "COLUMN" sections of the PivotTable Layout. The "Debit" and "Credit" fields are then summed in the "DATA" portion of the PivotTable.

My issue revolves around getting the actual impact for each account for each time period. Essentially, I need an extra column inserted between each time period that sums the debits and credits for that period. Do I need a macro for this (not any experience with macros)? My file is way to big to share, so let me know if a pared-down sample would work.

View 5 Replies View Related

Hide PivotTable Columns

Jul 17, 2007

Hide values in Column layout on pivot table i only want to show th total value as its based on quarter figures not per month and this way it looks like Quarterly totals are broken down per month and has to have 200 a mont whenits in fact 200 for the complete quarter, how can i had the 200 for each of the month and just have the total per country? This is what my pivot table looks like

county Month Quarterly totals

UK June 200
july 200
August 200

Uk Total 200

View 3 Replies View Related

Preserve Formatting In PivotTable

Sep 18, 2007

I have made a pivot table and in Pivot table option Merge labels for colum b. I the problem i am facing is once i give this the next colum text filed is automatically arranged in center. I want the next colum as left alignment. Once i delete some rows in the data then if i refresh it automatically align the next colum to center. I have given the preserve formatting as well as i have un selected the autoformat colum.

View 2 Replies View Related

Refresh All PivotTable In Workbook

Jan 10, 2008

I am trying to run a macro inside a Worksheet_Change event.

Private Sub Worksheet_Change(ByVal Target As Excel. Range)
If Not Application.Intersect(Target, Range("Mon_Data")) Is Nothing Then
If Target.Value > 0 Then
Sub Refresh_PivotTables()
'
' Refresh_PivotTables Macro
' Macro recorded 10/1/2008 by JackChappers
'

as you can see, i put the macro within the worksheet_Change event so that, when data is changed on another sheet (target.Value >0), the Macro is run (the macro, by the way, refreshes some Pivot Tables).

The refresh Refresh_PivotTables Macro works on it's own, but when i use it like this, i get the message:

"Compile error:

Ambiguous name detected: Worksheet_Change"

If it makes any difference, i also have another Worksheet_Change event above performing another action. I think that may be the problem, if it is, how do i run them both without the error?

View 4 Replies View Related

Unhide All PivotTable Fields

Jan 11, 2008

In a pivot table the user is able to select multiple entities to hide in the 'Hide Items' field of the PivotTable Fields window. I would like to create a macro (or edit a macro in the VB Editor) that willl reset all 'Hide Items' in the PivotTable Fields window...effectively unselecting any previously hidden entities.

View 2 Replies View Related







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