Results 1 to 2 of 2
  1. #1
    Legend1673 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2016
    Posts
    5

    Code Help: Using Field Value to Call Column Name

    I have two tables called "Current" and "Results". "Results" table has field "Code" which has a listing of all the column names from the "Current" table.

    Current Table
    A B C D E F
    1
    2
    3
    4

    Results Table
    Code CurrCount
    A
    B
    C
    D
    E
    F


    I am trying to populate results.currcount with the number of records in the corresponding column of the Current table with a value > 0. So basically, I'm trying to identify the current.<column> using the value in results.code.

    DoCmd.RunSQL "UPDATE Results " _


    & "SET currcount = DCount(""*"", ""Current"", code > 0 ) "

    Anyone able to help with the syntax or know of a better way??...

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    don't use domain functions (dcount, dsum, davg, etc) in queries, they are horribly inefficient in that context.

    I would use a crosstab query for this it seems the ideal solution.

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

Similar Threads

  1. Replies: 7
    Last Post: 05-22-2014, 06:17 AM
  2. Pause code until return from call command
    By trevor40 in forum Programming
    Replies: 1
    Last Post: 03-08-2014, 05:08 AM
  3. Call a Field created from a Query?
    By Heatshiver in forum Queries
    Replies: 4
    Last Post: 04-03-2012, 11:50 PM
  4. Code to call Split Form View Datasheet
    By ahightower in forum Programming
    Replies: 1
    Last Post: 07-28-2011, 04:57 PM
  5. Call .dll Code On BeforeUpdate?
    By phi11yguy19 in forum Programming
    Replies: 0
    Last Post: 07-02-2011, 10:20 PM

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