Results 1 to 2 of 2
  1. #1
    Aaron5714 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    48

    Avoiding "#Error" in Calculated Field

    In my database I have a form that shows details about a contract. This form has a calculated field that shows the last date that an audit was performed on the given contract. The control source for the calculated field is the following expression:

    =DMax("[AuditDate]","tblContractAudit","[ContractID] = " & [Forms]![frmContractDetail]![ContractID])

    This works fine, except when the user opens a blank version of the form to create a new record: until they start typing in any field, the autonumber ContractID field is not yet assigned a value which causes the calculated field to show #Error

    I tried wrapping the whole expression in Nz() but that did not seem to have an effect. Any advice on how to prevent #Error from showing before the ContractID is generated?



    Thanks,
    Aaron

  2. #2
    Aaron5714 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    48
    I was able to solve the problem using an IIf function to first test whether the ContractID field is null. The updated expression is:

    =IIf(IsNull([Forms]![frmContractDetail]![ContractID]),"",DMax("[AuditDate]","tblContractAudit","[ContractID] = " & [Forms]![frmContractDetail]![ContractID]))

    If anyone knows of a more elegant way to do this please let me know.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-08-2013, 12:59 PM
  2. Replies: 16
    Last Post: 07-22-2011, 09:23 AM
  3. Form error "the current field must match..."
    By plavookins in forum Forms
    Replies: 0
    Last Post: 04-13-2011, 07:42 AM
  4. "Group By" causes "ODBC--Call Failed" error
    By kaledev in forum Queries
    Replies: 1
    Last Post: 03-09-2011, 02:43 PM
  5. Replies: 8
    Last Post: 11-12-2010, 10:55 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