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

    Where Condition


    Hello,
    I have a command button on a main menu to open a form. I only want the forms opened showing the records where a particular field is null. I'm trying this code in a couple of different ways, but when I click the button, I'm always prompted for a parameter value of the LeadTech field. Here's the code...

    Dim stDoc As String
    Dim stCond As String
    stDoc = "frmWorkOrders"
    stCond = "txtLeadTech Is Null"
    DoCmd.OpenForm stDoc, acNormal, , stCond, acFormEdit

    I've also tried putting the condition right into the DoCmd line like this...

    DoCmd.OpenForm stDoc, acNormal, , "txtLeadTech Is Null"
    , acFormEdit
    with the same results. Any help out there this time of night? Thanks!

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Perhaps:
    DoCmd.OpenForm stDoc, acNormal, , "txtLeadTech" Is Null
    EDIT
    Please disregard the line above.
    DoCmd.OpenForm stDoc, acNormal, , "txtLeadTech Is Null", acFormEdit
    should work, if it doesn't work for you, can you tell us what happens when you try to use it.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Is the name of the field txtLeadTech or LeadTech?
    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.

  4. #4
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    The field name is txtLeadTech. It is actually a combobox with a Value List as the row source if that matters, and the Limit to List is No. When I click the command button on the menu, I get a parameters window that opens wanting me to enter the value for txtLeadTech. The query that the form is based on opens without a prompt, but it shows all work orders rather than just the ones that haven't been signed off yet by the lead tech.

  5. #5
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    I understand now June, my incorrect terminology messed me up! The combobox on the form is named txtLeadTech but the field in the query is just LeadTech. I changed the code to get rid of the txt part and it's now working right. Thank you both for your help.

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

Similar Threads

  1. Condition if there is a tempvar
    By Ruegen in forum Programming
    Replies: 1
    Last Post: 11-18-2013, 05:06 PM
  2. Help with using the AND condition
    By ssturges in forum Access
    Replies: 1
    Last Post: 11-25-2012, 12:36 AM
  3. IIF condition -Newbie
    By bldrc in forum Access
    Replies: 9
    Last Post: 07-21-2011, 01:30 PM
  4. DMax Condition
    By Luis Ferreira in forum Forms
    Replies: 3
    Last Post: 11-05-2010, 09:48 AM
  5. How to use IIF condition
    By nshaikh in forum Queries
    Replies: 4
    Last Post: 09-12-2008, 01:23 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