Solved

Complicated DSum formula problem

Posted on 2013-01-31
2
322 Views
Last Modified: 2013-02-01
I seem to have a syntax issue with:

'Display message box to warn user that excess inventory exists for this part number and allow for applied inventory qty ...
     If DSum("[Qty]", "tblFinGoods", "[PartN] = '" & Me.txtPart_No & "'") > 0 Then
                txtAppliedInvQty = InputBox("Excess inventory exists for this part number. Qty = " & (DSum("[Qty]", "tblFinGoods", "[PartN] = '" & Me.txtPart_No & "'") & " - " & (DSum("[AppliedInvQty]", "tblOpenOrders", "[Part_No] = '" & Me.txtPart_No & "'" And [Complete] = False) & " .  Enter the qty you want to apply to this order: (Be careful to enter the exact amount)")))

Can someone help me with this?
0
Comment
Question by:SteveL13
  • 2
2 Comments
 
LVL 57
ID: 38841495
Dim lngTotal as long

lngTotal = Nz(DSum("[Qty]", "tblFinGoods", "[PartN] = " & chr$(34) & Me.txtPart_No & chr$(34)) ,0)

If lngTotal > 0 then
   txtAppliedInvQty = InputBox("Excess inventory exists for this part number. Qty = " & lngTotal & " - " & DSum("[AppliedInvQty]", "tblOpenOrders", "[Part_No] = " & chr$(34) & Me.txtPart_No & chr$(34) & " And [Complete] = False) & ".  Enter the qty you want to apply to this order: (Be careful to enter the exact amount)")
End If

Give that a go...

Jim.
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 38841507
and if that doesn't work, break it down more like I did with lngTotal.  Ie.

Dim lngTotal as long
Dim lngTotal2 as long

lngTotal = Nz(DSum("[Qty]", "tblFinGoods", "[PartN] = " & chr$(34) & Me.txtPart_No & chr$(34)) ,0)

If lngTotal > 0 then
  lngTotal2 = DSum("[AppliedInvQty]", "tblOpenOrders", "[Part_No] = " & chr$(34) & Me.txtPart_No & chr$(34) & " And [Complete] = False")

   txtAppliedInvQty = InputBox("Excess inventory exists for this part number. Qty = " & lngTotal & " - " & lngTotal2 & ".  Enter the qty you want to apply to this order: (Be careful to enter the exact amount)")
End If

 until you get it.

Jim.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now