Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2022
    Posts
    17

    One table query giving different results

    Hi,
    Trying to create a query base on one table (Insurance Companies) in the table are four fields (Auto, Homeowners, Life, Renters). I know I'll able to select just one of these fields (Auto) to produce the desired result.
    My problem is I would like to use the same query and produce results on another field, say, Homeowners and so one. So, when I get to do a report, the report will prompt me for the field I wants for the results.
    Thanks for any help.
    Frank

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Fields referenced in query object cannot be dynamic. Field is included or it isn't. Cannot dynamically change unless you have VBA procedure to modify object via QueryDefs.

    Consider 'normalizing' with a related table where each insurance type is a record instead of a field. Then you filter for whatever insurance type you want. Or a UNION query can rearrange your current structure to a 'normalized' output that can be filtered like table.

    Otherwise, an IIf or Switch or Choose expression in query or textbox can return desired field value based on parameter. This calculated field would be ugly but doable.
    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
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    in the table are four fields (Auto, Homeowners, Life, Renters)
    I also figure the db is not normalized based on that statement. You probably designed it the same way you create spreadsheets because that's what you're used to. If you fix that problem now, a lot of issues like this will go away or never get raised in the first place. What you want to do can be accomplished by some kind of work-around (like making a choice on a form control that dictates which query thus which field to use for a report) but the idea is to eliminate the work arounds as much as possible. Using a UNION query is also an option, but I see that as needing another query to filter the 'normalized' results that it would create from un-normalized data, and all of that can be prevented from the get-go.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Query misfiring and giving wrong results
    By unclemeat in forum Queries
    Replies: 35
    Last Post: 04-10-2023, 02:38 AM
  2. Query giving strange results
    By deepakg27 in forum Queries
    Replies: 3
    Last Post: 02-11-2018, 11:17 AM
  3. Search Query not giving all results
    By wrkadri in forum Queries
    Replies: 5
    Last Post: 02-05-2013, 12:37 AM
  4. Calculation in Query giving wrong results
    By dargo72 in forum Queries
    Replies: 11
    Last Post: 11-07-2012, 05:39 AM
  5. Replies: 3
    Last Post: 07-13-2012, 09:18 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