Results 1 to 3 of 3
  1. #1
    PDS is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2022
    Posts
    1

    How to ask for what field name to use in query.

    My table has 100 fields named F1 to F100. I want to ask the user in a query what field do they want to sum values on due to so many fields.

    So in my query I have Var1: Sum(iif([F1]=1,1,0)) Var2: Sum(iif([F1]=2,1,0)).

    Rather than using F1, I want to ask the user which of the 100 fields do they want the calculations on.

    So it would 1st ask "what field do you want". If they answered F56, the above query would read:

    Var1: Sum(iif([F56]=1,1,0)) Var2: Sum(iif([F56]=2,1,0))



    Thank you!

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Var1: Sum(iif([Input Field Number]=1,1,0))
    You could try a parameter prompt as a simple solution. If they enter nothing and click you will likely get no results. If the field names have spaces they'll have use brackets around the field name. There are clues that you have a table design problem but I will leave it at that.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Sounds like not normalized at all?
    Are you an Excel person at all?

    I would use a combo for a field list for the table and work from that.

    Hopefully the user would know what on earth F56 is for?

    Perhaps give then a more descriptive name as to what they are meant to be choosing?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Replies: 2
    Last Post: 09-08-2021, 08:08 AM
  2. Replies: 2
    Last Post: 05-17-2017, 06:17 AM
  3. Replies: 10
    Last Post: 03-04-2015, 01:32 PM
  4. Replies: 3
    Last Post: 07-09-2014, 06:39 AM
  5. Replies: 3
    Last Post: 03-26-2014, 10:49 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