Results 1 to 3 of 3
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Allow Additions - New entry shows #Error

    I have a continuous form where two of the text boxes have Dlookups as their ControlSource. Everything looks fine except for the new addition boxes, as shown below:


    Click image for larger version. 

Name:	000.jpg 
Views:	12 
Size:	15.5 KB 
ID:	48045

    I'd like them to be either blank or some innocuous default string. Since there's no record upon which one can expect a valid return from the Dlookup, I understand the error.

    Not sure how to make sense of all of this. Maybe use a different approach to add new records?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Only carry out the dlookup when the value to be searched is entered. Do it via code.
    OR
    put dummy entries in the dlookup table for when values are null? In fact entry could be a ZLS ? could it not?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Thanks, I solved the issue in code:

    Code:
    Private Function fnPeriod(Per As Variant) As Variant
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '  Need the function sensitive to the case where there's no record, lest new
    '  addition fields appear as "#Error".
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    If Not IsNull(Per) Then
        fnPeriod = DLookup("PerName", "tblPeriods", "[Period] = " & Per)
    End If
    End Function
    Thanks for the suggestion,
    Bill

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

Similar Threads

  1. Syntax error only shows when loading report
    By Reginald in forum Programming
    Replies: 18
    Last Post: 03-25-2016, 05:33 PM
  2. Replies: 2
    Last Post: 12-11-2015, 02:55 PM
  3. DLookup text box on form shows error
    By Abacus1234 in forum Forms
    Replies: 8
    Last Post: 04-28-2015, 03:01 PM
  4. Replies: 2
    Last Post: 03-12-2014, 04:30 AM
  5. Replies: 1
    Last Post: 04-18-2012, 11:06 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