Results 1 to 6 of 6
  1. #1
    BillMc is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    2

    Created function as criteria

    Hi.


    I need to add string chosen from my combo box on the form to a query as filtering criteria. It didnt work directly so I loaded the chosen line from combo box by function. Then I used this function as criteria for query. It worked but I couldnt handle case when I dont choose anything from the combo box and in such case I would like to see all records. Insted of that it filtered out all records so I dont see any as result of query. Could u please help me? Thanks a lot

  2. #2
    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
    Please show related code.

  3. #3
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    BillMc -

    You might be able to use the following in the criteria row of the query.

    [Forms]![myForm]![myCombo] OR [Forms]![myForm]![myCombo] Is Null

    Change the names to reflect the name of your form and combo.

    Hope this helps,

    Jim

  4. #4
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    Orange

    Sorry, didn't see your post before I replied.

    All the best,

    Jim

  5. #5
    BillMc is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    2
    Dear Jim.
    Thanks for your suggestion but from some unknow reason this was not working so thats why I used function
    Function F1()
    F1=[Forms]![myForm]![myCombo]
    and than F1() was used as criteria in query which worked perfectly but I was not able to handle case where none of item from combo was chosen. Maybe the problem is that I am not able to find any controls for adding(not this combo nor textboxes) from my form when I use builder in query for adding criterias..... Thanks in advance
    Martin

  6. #6
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    Martin -

    Not sure I understand -

    "Maybe the problem is that I am not able to find any controls for adding(not this combo nor textboxes) from my form when I use builder in query for adding criterias."

    Can you post the db, less all sensitive data? Compact and repair, first, then zip.

    Thanks,

    Jim

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

Similar Threads

  1. Replies: 6
    Last Post: 01-07-2011, 12:50 PM
  2. Replies: 2
    Last Post: 12-22-2010, 09:57 AM
  3. Who created new record
    By ducecoop in forum Access
    Replies: 10
    Last Post: 10-28-2010, 02:50 PM
  4. How to work with .dbf file created by GIS
    By cowboy in forum Programming
    Replies: 8
    Last Post: 09-28-2010, 10:26 AM
  5. User created Hyperlink
    By kaylachris in forum Forms
    Replies: 3
    Last Post: 05-17-2010, 02:40 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