Results 1 to 7 of 7
  1. #1
    jlindquist23 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jan 2019
    Posts
    43

    #Name error in my form

    I have a query with a formula:
    BendTestsReq: IIf(Val([SageBTLot])=0,"",(IIf(Val([JO_Qty])<Val([SageBTMin]),Val([SageBTMin]),(Val([JO_Qty])/Val([SageBTLot]))*Val([SageBTQty]))))

    When I run the query, it shows the correct value:Click image for larger version. 

Name:	Capture1.PNG 
Views:	12 
Size:	19.5 KB 
ID:	39232
    When I add the field to my form, it shows this:


    Click image for larger version. 

Name:	Capture2.PNG 
Views:	12 
Size:	4.3 KB 
ID:	39233
    Not sure what is happening here. on the form it is setup as a general number with zero decimal points.
    Thanks!
    Jennifer

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    For some reason, Access can't find an object.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you are treating a single field as both text and a number for one thing. I doubt that's the main problem here but it doesn't help


    BendTestsReq: IIf(Val([SageBTLot])=0,0,(IIf(Val([JO_Qty])<Val([SageBTMin]),Val([SageBTMin]),(Val([JO_Qty])/Val([SageBTLot]))*Val([SageBTQty]))))

    BendTestsReq: IIf(Val([SageBTLot])=0,Null,(IIf(Val([JO_Qty])<Val([SageBTMin]),Val([SageBTMin]),(Val([JO_Qty])/Val([SageBTLot]))*Val([SageBTQty]))))

    either of these will work better

    use NULL if you don't want any value at all to appear, use 0 otherwise.

    If you try to sort your query after you run it (click a column header and choose a to z or z to a) I suspect you'll get an error. this usually happens when you've got a formula in your query Access can't interpret. For instance doing a date difference (DATEDIFF) calculation when one of the dates is missing, or adding a text value to a number field etc. If you do get an error you'll have to take out your calculated fields one at a time until you get the query to run, then figure out where the error is if it doesn't leap out at you.





  4. #4
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    Hmm, that will sometimes happen if the Control name on your Form is the same name as the Field name in your Query OR if your Control Name shares the name of one of the Fields in your calculation. Try giving the Control another name and see if that corrects the problem.

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Excellent point Gina, hadn't thought about that

  6. #6
    jlindquist23 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jan 2019
    Posts
    43
    Quote Originally Posted by GinaWhipp View Post
    Hmm, that will sometimes happen if the Control name on your Form is the same name as the Field name in your Query OR if your Control Name shares the name of one of the Fields in your calculation. Try giving the Control another name and see if that corrects the problem.
    I closed the database and reopened it and it worked. I ... can't... even...

  7. #7
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    Too funny but it does happen... go have some coffee!

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

Similar Threads

  1. Replies: 6
    Last Post: 03-17-2016, 02:10 PM
  2. Replies: 14
    Last Post: 03-31-2015, 05:20 PM
  3. Replies: 1
    Last Post: 11-18-2014, 12:35 PM
  4. Replies: 10
    Last Post: 10-22-2013, 07:35 AM
  5. Replies: 5
    Last Post: 12-22-2011, 01:12 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