Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2011
    Posts
    5

    Determine which fields are displayed in a query based on form checkboxes

    Hi,



    I'm not sure which forum to post this in as it's about both queries and forms.

    I have a form that I use to determine the Criteria to search my database. Currently the showallfields option is selected in the query. What I would like to do is have a checkbox for each field and allow the user to determine which fields they want to see.

    I've tried this:

    IIf([Forms]![SearchF]![ChkBoxMet]=0,Like "*" & [Forms]![SearchF]![Met] & "*",ColumnHidden[Query]![SearchQ]![Metabolite])

    but it doesn't work. Is there a better way to do this? I'm happy to do a bit a code writing but I may end up asking a lot more questions!

    Thanks,

    Gavin.

  2. #2
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Quote Originally Posted by GavinBlackburn View Post

    I've tried this:

    IIf([Forms]![SearchF]![ChkBoxMet]=0,Like "*" & [Forms]![SearchF]![Met] & "*",ColumnHidden[Query]![SearchQ]![Metabolite])
    Where have you put this bit? Is the user viewing the query? Why are they viewing a query vs. a sub-form?

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    I'm not sure what you intended that iif statement to do. I suggest you take a look at this tutorial by Martin Green on Building Queries on the Fly. I'm sure it will give you some valuable hints.

    http://www.fontstuff.com/access/acctut17.htm

    Good luck.

  4. #4
    Join Date
    Jul 2011
    Posts
    5
    Quote Originally Posted by jgelpi16 View Post
    Where have you put this bit? Is the user viewing the query? Why are they viewing a query vs. a sub-form?
    I put that bit in the Criteria section of the Query. I'm new to access and allowing them to view the query seemed the easiest way to display the data that was searched for.

  5. #5
    Join Date
    Jul 2011
    Posts
    5
    Quote Originally Posted by orange View Post
    I'm not sure what you intended that iif statement to do. I suggest you take a look at this tutorial by Martin Green on Building Queries on the Fly. I'm sure it will give you some valuable hints.

    http://www.fontstuff.com/access/acctut17.htm

    Good luck.

    Thanks for the link, I'll take a look but the database is quite simple so there aer not many different ways people can query it. The other issue is that it contains 40,000+ records so dropdown boxes aren't very useful for a lot of the fields.

    All i wanted the code to do was display a particular field if a particular check box was checked. It sounds straight-forward but I can't find a striaght-forward way to do it...

    Thanks,

    Gavin.

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

Similar Threads

  1. Form Based Query for Multiple Fields
    By sureelsaraf in forum Access
    Replies: 0
    Last Post: 03-28-2011, 06:14 PM
  2. Replies: 0
    Last Post: 03-06-2011, 04:10 AM
  3. Filter records based on multiple checkboxes
    By kbremner in forum Forms
    Replies: 2
    Last Post: 01-18-2011, 10:59 AM
  4. question about hidden fields and checkboxes
    By Nokia N93 in forum Access
    Replies: 2
    Last Post: 11-22-2010, 07:31 AM
  5. How do I determine a SQL query result?
    By Trainman in forum Database Design
    Replies: 1
    Last Post: 10-15-2009, 04: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