Cross-Table searches

Huey462

Board Regular
Joined
Jul 25, 2011
Messages
147
I have an access program with two databases, one that tracks all items that have been placed on order/awaiting order and the other lists all of the assets we keep on hand (nuts/bolts/etc). What I want to have Access do is when the Stock form (the one that shows what we keep on hand) is updated/current to have it run the following search:
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
Look in the SupplyLog table and add up the total for the Qty field each time the NSN fields match Me.NSN and the Status is either “Issued” or “Back-Order”
<o:p> </o:p>
I’m sure this will be some sort of DSum bit of code, but I’m essentially self taught and way out of my league on this one.
<o:p> </o:p>
Thanks in advance and let me know if you need to know something else.
-Foe
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
This was my best attempt at a formula

Code:
Me.QtyOnOrder.Value = DSum("[TotalPrice]", "SupplyLog", "[NSN]" = Me.NSN.Value And "[Status]" = "Issued")
 
Upvote 0
I’ve tried having the dsum reference the NSN value from the field itself as well as assigning it a temporary value with a DIM statement, neither of which works. I also fixed the field reference in the first [] to QTY
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
Code:
    Me.TempBox = NSNTemp
    ‘Puts value on screen to verify it is working/correct
        'Me.QtyOnOrder.Value = 0
        NSNTemp = DSum("[QTY]", "SupplyLog", "[NSN]" = Me.NSN.Value And "[Status]" = "Issued")
        Me.QtyOnOrder.Value = NSNTemp
 
Upvote 0
I finally figured this bit out, and the code works to go through and add up the total number of times each items is placed on order (example 1). How can I add an “and” statement to the end? Example 2 returns a compile error/syntax error.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> Example 1</o:p>
Code:
NSNTemp = DSum("[QTY]", "SupplyLog", "[NSN] = '" & Me.NSN.Value & "'"
<o:p> </o:p>
<o:p>Example 2</o:p>
Code:
NSNTemp = DSum("[QTY]", "SupplyLog", "[NSN] = '" & Me.NSN.Value & "'" AND [Status] = 'Issued'")
 
Upvote 0

Forum statistics

Threads
1,225,156
Messages
6,183,221
Members
453,152
Latest member
ChrisMd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top