Results 1 to 3 of 3
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Error Checking in a text box

    I use a dlookup function on a text box to get a report description of the report listed in a combo box. It looks like this.

    Code:
    =DLookUp("[Notes]","tbl_AccessObjects","Object_ID = [cboReport]")
    It works fine, unless the combo box is not populated yet in which case I get and #Error. So I put in some error checking which looks like this.



    Code:
     =IIf(IsError(DLookUp("[Notes]","tbl_AccessObjects","Object_ID = [cboReport]")),"",DLookUp("[Notes]","tbl_AccessObjects","Object_ID = [cboReport]"))
    )

    This has no effect at all. It works when the combo box is populated, gives #Error when it isn't.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Why use DLookup? Why not join tables? Don't use INNER JOIN if this is form RecordSource.

    Per Allen Browne http://allenbrowne.com/QueryPerfIssue.html: (Note: JET's IIf() is much more efficient than the similarly named function in VBA. The VBA one wastes time calculating both the True and False parts, and generates errors if either part does not work out (even if that part is not needed.) The JET IIf() does not have these problems.)

    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.

  3. #3
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    I ended up doing it in vba using the after update event of the combo box. This Report Info box was a late afterthought so I thought I could just pop a formula in there instead of adding another coded event, but really the VBA was much simpler and easier to troubleshoot.

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

Similar Threads

  1. Date checking code error
    By Huddle in forum Forms
    Replies: 1
    Last Post: 01-29-2015, 10:41 AM
  2. Error Checking Boxes
    By CementCarver in forum Access
    Replies: 2
    Last Post: 06-12-2013, 04:27 PM
  3. Error Checking within Form
    By phd4212 in forum Forms
    Replies: 1
    Last Post: 05-09-2012, 02:46 PM
  4. Error 0 problem with error checking
    By SemiAuto40 in forum Programming
    Replies: 4
    Last Post: 12-07-2011, 12:21 PM
  5. Date error checking
    By oediaz in forum Programming
    Replies: 2
    Last Post: 03-26-2010, 12:08 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