Science Forums
User Name
Password
Science Social Network
home    members    help/rules    who is online    contact   

Go Back   Science Forums > Physical Sciences Forums > Computer Science
Become a science forums sponsor today
Reply
 
LinkBack Thread Tools
Old 07-22-2008   #61 (permalink)
alexander's Avatar
Resident USSRian

Hypography Staff Member
Administrator
Gallery Curator
Dev Team Member

Latest blog entry:
Open-Source HIDS
 
alexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant future
Send a message via AIM to alexander
 



Re: Pyro's Excel Goodies

Pyro, the problem is that the macro does not seem to recognize the value, whether i cast it to a bool, or anything else, or not even cast it at all, it constantly has a type mismatch, and that, honestly, blows, not not got me a value that was easily checked and understood by the macro, and yeah simple

I thought the macro was rather brilliant, not all that many people use the xor logic never mind using xor logic on the value of the cell, to assign row properties...

I could have used NOT(cell) and reversed the logic, but it seemed more confusing...


----------------
And remember that great question that Pierre-Simon Laplace and Sir Isaac Newton, Andrei Markov and David Hilbert, Richard Feynman and Enrico Fermi, Albert Einstein and Edmund Halley did not come to ask throughout all of their dedication and work: "Who the hell is IMing me?"


This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.
Reply With Quote
Old 07-22-2008   #62 (permalink)
Pyrotex's Avatar
Slaying Bad Memes

Hypography Staff Member
Moderator
Editor

Latest blog entry:
I need a Vacation
 
Pyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond repute
Send a message via MSN to Pyrotex
 



Re: Pyro's Excel Goodies

Quote:
Originally Posted by alexander View Post
ok ...Problem i ran into was that the range function was returning a value that i couldn't even cast, it was so insanely weird, probalby due to what has to happen on the back end of the function or formatting or something....
Hmmmm, he said.
Whatever column you're checking on, make sure the "empty" cells don't have spaces in them. Like, " ", you know. A check on whether or not a cell is 0/1 or F/T can fail if the cell contains text.


----------------
Hypography Forums Moderator
-- - - - - -
What concerns me is not the way things are, but rather the way people think things are.
Epictetus, Greek Philosopher
The map is NOT the territory.
Korzybski, Polish-American Philosopher
Reply With Quote
Old 07-22-2008   #63 (permalink)
alexander's Avatar
Resident USSRian

Hypography Staff Member
Administrator
Gallery Curator
Dev Team Member

Latest blog entry:
Open-Source HIDS
 
alexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant futurealexander has a brilliant future
Send a message via AIM to alexander
 



Re: Pyro's Excel Goodies

i went through every data type in excel, i can't cast it as any of them! Not not was a quick solution that just works. Besides, the content of the field are generated via a formula, so i dunno if there is a space there or not :|


----------------
And remember that great question that Pierre-Simon Laplace and Sir Isaac Newton, Andrei Markov and David Hilbert, Richard Feynman and Enrico Fermi, Albert Einstein and Edmund Halley did not come to ask throughout all of their dedication and work: "Who the hell is IMing me?"


This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.
Reply With Quote
Old 08-29-2008   #64 (permalink)
TheBigDog's Avatar
Doing the Impossible

Hypography Staff Member
Moderator
Gallery Curator

 



Re: Pyro's Excel Goodies

O Great Sage of Excel!! I come to the humbly to partake from your vast grid of wisdom.

I have a spreadsheet that I have distributed as an analysis tool. It essentially is two pieces. 1) An Access DB used to store data for analysis on the users local computer. 2) An Excel document that does the analysis of the data. When the user opens the sheet they use a UserForm to update their local Access database from a centralized SQL server. That is not the problem. Once the data is updated in the Access database I have the pivot tables in the Excel file all update. That is not the problem. The problem is coming as I try to add some sophistication to the update procedure.

Because the data set is getting larger I am giving the users the ability to filter what data is queried from Access into Excel. It is doing an analysis of all the product that passes through our manufacturing process. I trap the major events as "Milestones". I allow the user to select which Milestones they want to include in the data loaded to the pivot tables. I have the code working that creates the SQL query from their selections, but when I try and update the ThisWorkbook.PivotCaches(1).CommandText = sql I get an error 1004. I looked this up on the internet and found the problem is that I have several pivot tables all referencing this pivot table as the source - I do this to best utilize memory and to make it so I only have to do one refresh to update all the pivot tables.

My question is this... Do you know of a way I can update the CommandText property of the pivot caches object? I found some code on the net that is supposed to do it by updating the .Connection to change the .QueryType from ODBC to OLE and then back again after making the update, but it is not working. My next route is to decouple all of the pivot tables, update the .CommandText on the primary table, and then link them all to it again. But I figured I would check with you before I ran down that rabbit hole too far.

I hope you can help with this one! It has be pretty flustered.

Thanks!

Bill


----------------
aka TheBigDog - Hypography Full Freaking Moderator
Become a Hypography sponsor!
The truth is incontravertible; malice may attack it, ignorance may deride it, but in the end there it is. - Winston Churchill

TheBigDog's recommended reading: The Science of Success - Charles G. Koch

A neutron goes into a bar and asks the bartender, "How much for a beer?"
The bartender replies, "For you, no charge."
Reply With Quote
Old 08-29-2008   #65 (permalink)
Pyrotex's Avatar
Slaying Bad Memes

Hypography Staff Member
Moderator
Editor

Latest blog entry:
I need a Vacation
 
Pyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond reputePyrotex has a reputation beyond repute
Send a message via MSN to Pyrotex
 



Re: Pyro's Excel Goodies

Quote:
Originally Posted by TheBigDog View Post
...I have a spreadsheet ...Access database from a centralized SQL server ...ThisWorkbook.PivotCaches(1).CommandText = sql ...error 1004 ...one refresh to update all the pivot tables ...update the CommandText property of the pivot caches object? ...change the .QueryType from ODBC to OLE ...decouple all of the pivot tables...rabbit hole ...flustered...


Uh... maybe if you SQL Pivot the decouple Command refresh between Access and the ODBC rabbit hole ...

I am sorry old friend, but I cannot even begin to start to commence to solve your problem. I have never tried to cross-couple Excel and Access.
Sorry again.


----------------
Hypography Forums Moderator
-- - - - - -
What concerns me is not the way things are, but rather the way people think things are.
Epictetus, Greek Philosopher
The map is NOT the territory.
Korzybski, Polish-American Philosopher
Reply With Quote
Old 10-18-2008   #66 (permalink)
TheBigDog's Avatar
Doing the Impossible

Hypography Staff Member
Moderator
Gallery Curator

 



Post Re: Pyro's Excel Goodies

Quote:
Originally Posted by Pyrotex View Post


Uh... maybe if you SQL Pivot the decouple Command refresh between Access and the ODBC rabbit hole ...

I am sorry old friend, but I cannot even begin to start to commence to solve your problem. I have never tried to cross-couple Excel and Access.
Sorry again.
I solved the problem by going to the source. Instead of changing the query that extracts data from Access, I modify the Access query to filter out the data I don't want to see. This works like a charm. Here is what I do...

My pivot table is linked to an Access Query called Q1. I made a copy of that query called Q2. Neither Q1 nor Q2 have a WHERE clause. An Access Query is just a SQL statement saved as an object in Access.

With my code in Excel I have a tool for selecting the way the user wants to filter the data. I use this to make a WHERE clause. I then copy the Q2 SQL statement to a string, append the WHERE clause to it, and make it the new Q1 where clause. Then I refresh the pivot tables and voila.

Code:
Sub UpdateMilestonesQuery()

'Declare the variables I will use for this procedure
'Even when Option Explicit is false this is good form
    
'I use the "?_jet" to indicate objects used for working with Access (Jet)
'I do this because in many routines I will have connections to multiple sources of multiple types
    Dim wrk_jet As Workspace
    Dim db_jet As Database
    Dim qdf1_jet As QueryDef
    Dim qdf2_jet As QueryDef
    Dim sql_jet As String

'Establish connection to the Jet database
    Set wrk_jet = CreateWorkspace("NewJetWorkspace", "admin", "", dbUseJet)
    Set db_jet = wrk_jet.OpenDatabase(Setting("DWLocal"))
    Set qdf1_jet = db_jet.QueryDefs(Setting("DWLinkedQuery"))
    Set qdf2_jet = db_jet.QueryDefs(Setting("DWStaticQuery"))
    
    qdf1_jet.sql = _
        qdf2_jet.sql & " " & _
        "WHERE ([" & Setting("DWLinkedQuery") & "].[Milestones] IN (" & Setting("IncludeMilestones") & ")" & _
        "AND (" & Setting("DWLinkedQuery") & ".Plant IN (" & Setting("IncludedPlants") & ")) "

    db_jet.close

    RefreshPivotTables ThisWorkbook

End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Below here are the other functions and subroutines that are called during the process. 

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub UpdatePivotTables(ByVal wb As Workbook)

    Dim x as PivotCache
    Dim Count as Integer

    For Each x In wb.PivotCaches
        Count = Count + 1
        UpdateLog ("Refreshing pivot table data (" & Count & " of " & wb.PivotCaches.Count & ")")
        x.Refresh
    Next

End Sub

Function Setting(ByVal Field As String)

    Dim wrk_jet As Workspace
    Dim db_jet As Database
    Dim rst_jet As Recordset
    
'Establish connection to the Jet database
'Note that I have hard coded the location of the settings database.
'This is because it cannot call itself to find itself.
'My next version will include use of the Windows Registry to store the location of the settings DB.

    Set wrk_jet = CreateWorkspace("NewJetWorkspace", "admin", "", dbUseJet)
    Set db_jet = wrk_jet.OpenDatabase("C:\Projects\Settings.mdb")
    rst_jet = db_jet.OpenRecordset("SELECT Value FROM Settings WHERE Field = '" & Field & "'")
    
    If rst_jet.EOF = False Then
        Settings = rst_jet.Fields("Field").Value
    Else
        Settings = ""
    End If
    
    db_jet.Close
    
End Function

Sub UpdateLog(ByVal Message As String)

On Error Resume Next

'Writes to the screen
    txt_Log.Text = txt_Log.Text & Format(Now, Setting("LogTimeFormat") & " - " & Message & Chr(13)
    txt_Log.SetFocus
    
'Writes to the log file
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set a = fs.Opentextfile(Setting("LogPath"), 8, True)
    a.writeline (Format(Now, Setting("LogDateTimeFormat") & " - " & Message & Chr(13))
    a.Close
    DoEvents
    
End Sub


----------------
aka TheBigDog - Hypography Full Freaking Moderator
Become a Hypography sponsor!
The truth is incontravertible; malice may attack it, ignorance may deride it, but in the end there it is. - Winston Churchill

TheBigDog's recommended reading: The Science of Success - Charles G. Koch

A neutron goes into a bar and asks the bartender, "How much for a beer?"
The bartender replies, "For you, no charge."
Reply With Quote
Reply

Bookmarks

Tags
excel, formulas, macros, spreadsheet, spreadsheets, vba


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 compatibility freeztar User feedback 11 01-29-2008 09:14 PM
How to convert Ms. Excel spreadsheet to MS. SQL? cannonbow88 Computer Science 2 09-27-2006 05:52 AM
How to convert MS Excel format to My SQL? Chloe Computer Science 5 08-11-2005 08:23 PM


All times are GMT -8. The time now is 01:08 PM.

Hypography?

Hypography [n.]: A combination of "hyperlink" and "bibliography" - ie, a list of links to electronic documents. Comparable to discography and bibliography, but not cartography.

We have been online since May 2000, and aim to be the best place to find and share science-related content of all kinds.

Share the love!

Please add more science to your life. Use our RSS feeds on your blog, your portal, or your favorite feedreader!

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc. Copyright © 2000-2008 Hypography
Part of the Hypography - Science for Everyone Network