Results 1 to 3 of 3
  1. #1
    WC_Bill is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    2

    Dynamic crosstab query clears while running VBA code from button click.


    Direct Issue:
    I'm trying to get the column count of a dynamic crosstab query in VBA code, but while the code is running, the crosstab query clears, so Fields.Count = 0. This issue happens when I run any VBA code (trigger by button click or combo box update). Is there anyway to get a dynamic crosstab query to actually contain data while VBA code is running?

    Bigger situation:
    I'm trying to force a subform to use my dynamic crosstab query as it's source object (Normally one would get the "Can't use non fixed column crosstab as source object" error). I figure I might be able to do that by compiling a string of column names and then forming a new query with the column names hard coded in. The appropriate query is formed by selecting an option from a combo box on the form (an 'on update' even triggers and forms the SQL statement in VBA code), and I can open that query and view it just fine after that code finishes, but when code runs from a button click (even If I put a debug breakpoint before the code refers to any queries) the query goes blank until that code finishes, thus my problem.

    The number of columns vary depending on the user choice in the combo box. Both of my dynamic queries will clear out (even though one has nothing to do with the code being run). I've done a lot of searching, but I couldn't find any work-arounds for this. Could I create a whole new table based on my query? I'm not seeing how that would work.

    I can post my code if it'll help, but I figure i'll not cram this first post with 71 line of code.

    Thanks in advance.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    If your vba code is
    msgbox Dcount("*","qxCrosstab")

    I dont see any code here that would 'clear' the data.

  3. #3
    WC_Bill is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    2
    I don't think we're on the same page. Does "Dcount("*","qxCrosstab")" count the number of columns or number of records? I need the number of columns (and for those columns to be present). I don't think any of my code is actually clearing my crosstabs (not intentionally anyways, but when any code runs, the queries appear blank for some reason.

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

Similar Threads

  1. Replies: 24
    Last Post: 02-20-2013, 09:46 PM
  2. Running a module from a button click
    By adacpt in forum Modules
    Replies: 4
    Last Post: 12-03-2012, 01:09 PM
  3. Replies: 2
    Last Post: 03-22-2012, 01:01 AM
  4. Replies: 1
    Last Post: 07-30-2010, 10:28 AM
  5. Dynamic Column Headers but NOT CROSSTAB
    By jtkjames in forum Queries
    Replies: 1
    Last Post: 07-26-2010, 05:16 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