Results 1 to 4 of 4
  1. #1
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273

    Where Condition when opening a form

    I hope this has an easy answer.


    I'm trying to open a form that only shows a quantity greater than zero, but I can't get the syntax quite right.

    Dim strDocName As String
    strDocName = "frmInventory"
    DoCmd.OpenForm strDocName, , , "Qty >0"

    Since this opens the form and still shows items with "0" quantity, how do I need to word this?
    The zero quantities are kept in the database for restocking purposes, so we don't want to delete them, and then have to reenter all of the info when restocked, just enter the new quantity.

    Thanks for the help!

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    providing Qty is the name of your field and it is a numeric datatype then it should work. Also if Qty is a double, are your sure it doesn't have values like 0.00001 which are formatted to appear as 0.00?

    If it is not one of these, something else is wrong - so what is the recordsource to your form? if a query what is the sql?.

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    also, if you're applying a filter (which appears to be what you're doing) you have to set the form to allow filters as well as supplying the filter string

  4. #4
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    Thanks for the responses, I found the problem. The form opens with a filter, and the first part of the code clears all filters to start fresh, negating what I was trying to do in the beginning.
    Thanks again.

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

Similar Threads

  1. Replies: 5
    Last Post: 01-24-2015, 12:59 AM
  2. opening a form when condition is met
    By webisti in forum Programming
    Replies: 2
    Last Post: 03-06-2014, 02:39 AM
  3. If Statement Condition - Opening Report
    By geraldk in forum Reports
    Replies: 3
    Last Post: 07-10-2013, 10:26 AM
  4. where condition with Navigation form
    By hyman in forum Forms
    Replies: 0
    Last Post: 10-31-2012, 02:39 AM
  5. Where Condition - form error
    By catat in forum Forms
    Replies: 5
    Last Post: 07-15-2010, 07:40 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