Results 1 to 9 of 9
  1. #1
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283

    CrossTab Query as a source for a query to update Format

    I used Allen Browne's method (http://allenbrowne.com/ser-67.html) to populate 2 values in a crosstab query. The first value is a number of dials, the second value is the duration of the calls in seconds. This is working as expected.

    I am wondering though if it is possible to use the crosstab query as the source to update the format of the duration from seconds to hh:mm:ss or to format just the duration portion of the results during execution. When the initial crosstab is run it generates the values as Date + Dials and Date + TT

    Currently I use the following to obtain the 2 values for the crosstab, with the values of Dials and TT as rows in the tblXTabColumns table per Allen Browne.



    Code:
    TheValue: Sum(IIf([FldName]="DIALS",CDbl([DIALS].[DIALS]),CDbl([TALKTIME].[CUST_TT])))
    When the final crosstab is run it creates a dials column and a TT column for each day of the month as the data flows into the base tables. So day 1 it returns 2 columns and on the 30th day it returns 60 columns. It is here where I am running into the issue of formatting. I have not been able to get it formatted during execution and I am unsure if I can get it formatted using the crosstab as a query source.

    Any advice as always is appreciated

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What do you mean by 'update format'? You want to modify value in table? Why? Did you try using the CROSSTAB in another query and apply formatting?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283
    I have been trying to use the Crosstab in another query to update formatting but I seem to always get Data Type Mismatch for every row.

    I was trying

    Code:
    Update tblExport_Temp
    Set [TheValue] = Format([TheValue]/86400, "hh:nn:ss")
    Where Expr2 like '*TT'

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Again, why would you update a table? Export query.

    Format() returns a string value. If you are trying to update a number or Date type field, that would cause Mismatch.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283
    I thought I had to save the data to a table in order to get the seconds converted to hh:mm:ss, How would you recommend I perform that step? I appreciate you time and apologize for my thickness, new to this.

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Create a query to reformat the field, save it as a standard query that you can use everywhere in your system whenever you need that format. For instance, your crosstab query would then bring in this query and join it to the table on primary key, and will take the field from there already formatted instead of worrying about having to do it in the crosstab.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Issue originally discussed in http://stackoverflow.com/questions/4...54057#43854057

    @aytee111 How would the CROSSTAB join with standard query? CROSSTAB is an aggregation of data. Primary keys are not in CROSSTAB. Also, the standard or GROUP BY query has data vertical whereas in the CROSSTAB it is horizontal, how would you associate the values?

    @Mindbender If you used the query builder to construct the UPDATE query should be able to do same for a SELECT using the same Format() expression.


    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283
    Quote Originally Posted by June7 View Post
    Issue original discussed in http://stackoverflow.com/questions/4...54057#43854057

    @aytee111 How would the CROSSTAB join with standard query? CROSSTAB is an aggregation of data. Primary keys are not in CROSSTAB. Also, the standard or GROUP BY query has data vertical whereas in the CROSSTAB it is horizontal, how would you associate the values?

    @Mindbender If you used the query builder to construct the UPDATE query should be able to do same for a SELECT using the same Format() expression.


    I will try that thanks

  9. #9
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283
    I got it formatted the way I wanted it now. Thank you very much for the help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 11-24-2014, 02:19 PM
  2. Replies: 7
    Last Post: 08-26-2013, 06:05 AM
  3. Replies: 4
    Last Post: 11-21-2012, 03:17 PM
  4. Replies: 20
    Last Post: 02-14-2011, 10:55 AM
  5. Replies: 1
    Last Post: 09-05-2010, 11:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums