Results 1 to 11 of 11
  1. #1
    FRSPA is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    7

    form with variable field number

    I would like to show in a form a dynamic cross analysis query which can have a varying number of columns that all have to be displayed anytime. I don't know how to do this.



    Thanks for help.

    FR

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Does cross analysis query mean crosstab query? I have little experience with crosstabs but maybe using datasheet view in the form will handle this.

  3. #3
    FRSPA is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    7
    Yes I mean Crosstab query. Unfortunately, I'm already using the datasheet view in my form but once the form is created, if I add data to my source table that request an additional column in the display, it is not shown...

    Note that to create the form, I originally used the assistant, which created a form based on my crosstab query with a determinated number of fields shown in the creation mode. These fields are then displayed as datasheet in the form mode.

    P.S.: Sorry for my poor translation of technical terms... I'm working with a french version.

    Thanks for help,

    FR

  4. #4
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Look at this video on creating cross tab queries.

    http://www.datapigtechnologies.com/f.../crosstab.html

    Alan

  5. #5
    FRSPA is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    7
    Sorry Mr Sidman. My problem is not creating crosstab queries but rather displaying them in a form that would show a varying number of rows or columns...

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Oh, of course, just hit me that the form would still require controls to be added even if using datasheet view. You could programmatically add controls to form. Basically, build the form each time it is opened. I have never done this, but seen code.

  7. #7
    FRSPA is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    7
    Thanks for this hint. If you can have a rapid hand on this sample code I would be interested. If not its OK.

    Thanks a lot,

    FR

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    You might search on "dynamic crosstab". Methods I've seen (and use) involve a form/report with the maximum possible number of controls pre-built. Code in the open event examines the source query and assigns control sources or hides controls as appropriate. To me this is simpler than adding controls, as then you have to position them. I use code from the Access Developer's Handbook, so I don't think it's kosher for me to post the code (copyright violation).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    pbaldy's alternative sounds reasonable. Although with displaying form in datasheet view positioning the created controls is not critical. However, creating controls requires programmatically opening the form in DesignView first then switching to FormView (not necessary to save the revised form). pbaldy's suggestion skips the DesignView step.

  11. #11
    FRSPA is offline Novice
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    7
    Thanks to all for your help. I will look further on my side through this avenue.

    FR

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

Similar Threads

  1. Replies: 4
    Last Post: 04-18-2011, 07:18 AM
  2. VBA DCount() with variable field name
    By drh in forum Programming
    Replies: 2
    Last Post: 07-13-2010, 12:36 AM
  3. set date field on form to date variable
    By laavista in forum Access
    Replies: 3
    Last Post: 06-28-2010, 03:03 AM
  4. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  5. Replies: 38
    Last Post: 05-21-2010, 11:56 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