Results 1 to 4 of 4
  1. #1
    pawjer is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    8

    DoCmd.OpenForm when WHERE contains Null and something else

    I have a form containing a button that opens form called e.g Cars. I have added VBA code to that button that opens mentioned form. However I would like to filter that form to records where field "IdGroup" has


    [List0] value either is Null.

    When I put WHERE conditions separately, I get an appropriate result for Null and for the value from
    [List0].

    DoCmd.OpenForm "frmCars", acNormal, , "[IdGroup] Is Null"

    DoCmd.OpenForm "frmCars", acNormal, , "[IdGroup]=" &
    [List0]

    Both work fine, but I need to have WHERE combined out of those two. I got error when I put the following:

    DoCmd.OpenForm "frmCars", acNormal, , "[IdGroup] Is Null" Or "[IdGroup]=" &
    [List0]

    I am almost sure I am not using OR operator correctly. It is probably quite easy but I cannot figure it out how it should be done.

    I would be grateful for correction of the las VBA line presented.

    Thank in advance,

    Kind regards,

    Paweł

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    you need to combine into one string

    "[IdGroup] Is Null Or [IdGroup]=" &
    [List0]

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    then you dont need the where at all.

    is List0 a list, or a value?
    if value , is it a string or number?

  4. #4
    pawjer is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    8
    I've tried it. Works perfectly. Many thank for help.

    However I don't really get this combination of quotation marks, especially the one just before "&" sign. I think I have to read and learn more

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

Similar Threads

  1. Replies: 11
    Last Post: 08-22-2017, 05:50 PM
  2. DoCmd.OpenForm with multiple macros
    By Ekhart in forum Access
    Replies: 2
    Last Post: 03-02-2017, 01:38 PM
  3. DoCmd.OpenForm with 2 Where Conditions
    By CharissaBelle in forum Programming
    Replies: 3
    Last Post: 10-19-2016, 09:32 AM
  4. What actually happens at docmd.openform
    By Beorn in forum Programming
    Replies: 4
    Last Post: 01-05-2011, 02:19 PM
  5. DoCmd.OpenForm Modification
    By alsoto in forum Forms
    Replies: 6
    Last Post: 05-01-2009, 07:28 AM

Tags for this Thread

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