Results 1 to 3 of 3
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195

    Calculation problem

    Hi Guy's can anyone help with this one please



    I have 3 item numbers in tblEdit with 200871 added with status planning

    tblStock shows we have got 3 in stock

    i am wanting to achieve looking up if any of this number is allocated ie: planning or on hold and recalculate in the stock table the following

    StartQty 3
    Allocated Qty 3
    NewQty 0

    The following is the code i have that is returning

    StartQty 3
    AllocatedQty 10769
    NewQty -10766

    There was only ever 3 in stock ?????

    Code:
    Dim mHold As String, mPlan As StringDim mLiftNo As Long, mStartQty As Long, mAllocated As Long, mNewQty As Long
    
    
    mStartQty = Me.StartQty
    mLiftNo = Me.LiftNo
    mHold = "On Hold"
    mPlan = "Planning"
    
    
    If mStartQty > 0 Then
    If IsNull(mAllocated = DCount("DelTo", "tblEdit", "[LiftNo] Like ""*" & mLiftNo & "*""" & " And [Status] = '" & mHold & "'" & " Or '" & mPlan & "'")) Then
    mAllocated = "0"
    mNewQty = "0"
    Me.AllocatedQty = mAllocated
    Me.NewQty = "0"
    Else
    mAllocated = DCount("DelTo", "tblEdit", "[LiftNo] Like ""*" & mLiftNo & "*""" & " And [Status] = '" & mHold & "'" & " Or '" & mPlan & "'")
    mNewQty = mStartQty - mAllocated
    Me.AllocatedQty = mAllocated
    Me.NewQty = mNewQty
    End If
    End If
    Attached Thumbnails Attached Thumbnails 200817.JPG  

  2. #2
    Minty is online now VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Create a normal query with some hard coded values to get your check your dcount results.

    I would suspect your use of wildcards is messing with your results - this bit "[LiftNo] Like ""*" & mLiftNo & "*""" does not look right to me at all .
    It should look like
    "[LiftNo] Like *" & mLiftNo & "* AND "

    If your mLiftnumber is a zero length string or null it will return everything ,same with your other criteria.

    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Thank you minty, it was excatly what you said, changed the way it was looking up and worked, thank you

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

Similar Threads

  1. Solving a Calculation Problem
    By DigitalAdrenaline in forum Programming
    Replies: 0
    Last Post: 08-19-2018, 06:52 AM
  2. Problem with Calculation on Report using IIF
    By pdlecesne in forum Reports
    Replies: 5
    Last Post: 02-28-2013, 12:44 PM
  3. Another calculation problem
    By stryder09 in forum Access
    Replies: 8
    Last Post: 03-08-2011, 03:11 PM
  4. another calculation problem
    By stryder09 in forum Access
    Replies: 15
    Last Post: 02-11-2011, 04:53 PM
  5. Calculation problem
    By cometdragon in forum Queries
    Replies: 2
    Last Post: 07-28-2010, 08:54 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