Results 1 to 4 of 4
  1. #1
    sleake is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    51

    Fill check box when another field is not empty

    I've created an unbound check box for display on a form that I want to fill (-1) when an Attachment field is not empty. (Just want to know whether there is an attachment.)



    I tried creating an expression as the control source of the check box, but received an error about incorrect syntax.

    Here's the expression I tried: Iif (Not IsEmpty(AttachmentField, -1, 0)).

    Would appreciate your help.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I would try putting code in the On Current Event.

  3. #3
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    One half of the IIF expression is what to do if true, the other part is for what to do if it's not, so you don't use the logical operator "Not". you could use an event (AfterUpdate or LostFocus, or maybe even Change) on the textbox to set the checkbox to be True or False when that event fires. Or you could try =IIf(IsNull([AttachmentField]),0,-1).
    IsEmpty is supposed to be used for a varaiant data type, which I doubt your textbox is.
    Last edited by Micron; 01-25-2016 at 04:57 PM. Reason: IsEmpty
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    While the argument is a Variant containing a numeric or string expression...IsEmpty() actually indicates whether or not a Variable has been initialized.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Query syntax to fill a field if empty
    By louise in forum Queries
    Replies: 4
    Last Post: 07-21-2015, 07:26 AM
  2. Replies: 5
    Last Post: 01-13-2015, 11:57 AM
  3. Replies: 1
    Last Post: 04-15-2014, 02:45 PM
  4. Code to check if field is empty
    By darekg11 in forum Forms
    Replies: 2
    Last Post: 09-18-2012, 03:15 PM
  5. check empty table
    By ramdandi in forum Queries
    Replies: 1
    Last Post: 12-20-2011, 04:31 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