Results 1 to 9 of 9
  1. #1
    dmyoungsal is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    May 2018
    Posts
    27

    #error

    I am updating a form and have embeded the following into an unbound field, but when opening the form, the field displays "#Error"



    =IIf([chkSDel]="-1",[tbxSlsRate],IIf([chkTMgrDel]="-1",[tbxSlsRate],IIf([from]="Stockton",[tbxStckRate],IIf([from]="Yuma",[tbxYumaRate],[tbxTruckRate]))))

    The fields causing the problem are: [tbxSlsRate]; [tbxStckRate]; [tbxYumaRate]; [tbxTruckRate]

    These fields are from 4 separate Dlookups in other fields looking at a query (i.e. =DLookUp("[TRKRate]","qryTruckRate")) which display the numbers contained in the fields in the query. In the case of the Dlookup, the field is named "tbxTruckRate"

    Here is the contents of the original field (I am converting from embedded numbers to using a table that I can change the rates on the fly:
    =IIf([chkSDel]="-1","75.00",IIf([chkTMgrDel]="-1","75.00",IIf([from]="Stockton","135.00",IIf([from]="Yuma","145.00","145.00"))))

    any suggestions will be helpful.

  2. #2
    dmyoungsal is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    May 2018
    Posts
    27
    the form using the lower "iif" statement has been in use for about 4 years.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    why are you using quotations around all your values?

    chkSDel and chkTMgrDel implies a check box which is a yes/no value with is numeric, not text
    all the other fields appear to return numeric values, but you treat as text

    please clarify the datatype for each value and what those values are - if you have any nulls, that will be one reason

  4. #4
    dmyoungsal is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    May 2018
    Posts
    27
    Quote Originally Posted by CJ_London View Post
    why are you using quotations around all your values?

    chkSDel and chkTMgrDel implies a check box which is a yes/no value with is numeric, not text
    all the other fields appear to return numeric values, but you treat as text

    please clarify the datatype for each value and what those values are - if you have any nulls, that will be one reason
    Thanks for that input.... since I wrote this form some time ago, I do not recall why i put quotes around it, but removing them did not cause any problems.

    When I open the form, the field I am having a problem with shows correctly (default of "140.00" - which comes from another field in the form ("txtTruckRate" = DLOOKUP("[TrkRate]","qryTruckRate")

    but when i change the contents of the "from" field (which controls the contents of TruckRate field), the #error appears

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    just because the value is a number does not mean the field type is numeric, it may be a text field presenting a number. suggest substitute your dlookup in your formula

    =IIf([chkSDel]="-1",[tbxSlsRate],IIf([chkTMgrDel]="-1",dlookup(....),IIf([from]="Stockton",dlookup(....),IIf([from]="Yuma",dlookup(....),DLOOKUP("[TrkRate]","qryTruckRate")))))

    or better still, include your qryTruckRate in your recordset and calculate it there

  6. #6
    dmyoungsal is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    May 2018
    Posts
    27
    after responding to your last comment (again, thanks), i had the exact thought about incorporating the "dlookup" into the areas that I was feeding the "txt" variables into. I literally just tested it and it worked flawlessly. Thanks for the inspiration.

  7. #7
    dmyoungsal is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    May 2018
    Posts
    27
    CJ_London...... thank you!

  8. #8
    dmyoungsal is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    May 2018
    Posts
    27

    Periodic fail

    Quote Originally Posted by dmyoungsal View Post
    after responding to your last comment (again, thanks), i had the exact thought about incorporating the "dlookup" into the areas that I was feeding the "txt" variables into. I literally just tested it and it worked flawlessly. Thanks for the inspiration.
    I have another form that I use for pulling up a previous quote (that is essentially the same form and uses the same fields) and it works "most" of the time. I can select (or a different location in the "from" field and the Truck Rate appears correctly, and the calculation using the TruckRate field works, but every once in a while, I get a "type" error. But if I reenter or select another location, the calculation works fine.

    A head scratcher/

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    That will likely be your data at fault?
    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

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

Similar Threads

  1. Replies: 5
    Last Post: 07-15-2019, 10:20 AM
  2. Replies: 13
    Last Post: 05-31-2019, 10:48 PM
  3. Replies: 1
    Last Post: 07-26-2016, 06:34 AM
  4. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  5. Replies: 0
    Last Post: 07-16-2012, 05:42 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