473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

procedure to change inventory from the invoice qty

Hello everybody,
I want to know if anybody can help me. What procedure or code can be used if I want to do the following.
I have a invoice entry form and a inventory/stock form showing stock and qty.
If a qty is entered on the invoice form and I click a button "print invoice" I want the qty that is on the invoice to be subtracted from the qty in stock.
I have tried many on click events to minus the one from the other but didn't work out properly.
If you want me to give you details of what tables I have etc, please ask. But for now I just want an explanation of what to do where so that a procedure can handle this for me.

Thanking you.
Ryno
Dec 24 '10 #1

✓ answered by RuralGuy

Instead of
DoCmd.RunSQL SQL
...use
CurrentDB.Execute SQL, dbFailOnError

5 4652
MikeTheBike
639 Expert 512MB
Hi

I don't know what youe level of expertise is with queries/SQL, but you could create an stored action query linked to this form referring to the Invoiced quantity (ie an Update query), to update the 'Stock' table after the invoice has printed successfully.

ie DoCmd.RunSQL "StoredQueryName"

You could also create the query in code something like this

Expand|Select|Wrap|Line Numbers
  1. Dim SQL As String
  2.  
  3.     SQL = "UPDATE StockTableName " & _
  4.           "SET StockTableName.Quantity = StockTableName.Quantity -" & Me.InvoiceQuantityControl.Value & " " & _
  5.           "WHERE StockTableName.ID = " & Me.ID
  6.  
  7.     DoCmd.RunSQL SQL

MTB
Dec 24 '10 #2
Hello

Thanks for your reply. I used the following code, but when I click the button, it wants me to enter a parameter value and I dont know why.

This is what I have

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command11_Click()
  2. Dim SQL As String
  3.  
  4.     SQL = "UPDATE Inventory " & _
  5.           "SET Inventory.QtyOnHand = Inventory.QtyOnHand -" & Me.ShipQty.Value & " " & _
  6.           "WHERE Inventory.StockCode = " & Me.StockCode
  7.  
  8.     DoCmd.RunSQL SQL
  9. End Sub
Dec 24 '10 #3
RuralGuy
375 Expert 256MB
Try:
Expand|Select|Wrap|Line Numbers
  1. SQL = "UPDATE Inventory " & _ 
  2.             "SET Inventory.QtyOnHand = Inventory.QtyOnHand - " & Me.ShipQty & _ 
  3.             " WHERE Inventory.StockCode = '" & Me.StockCode & "';"
...if StockCode is a String field.
Dec 26 '10 #4
HI,

Thank you very much, this code works and does not ask for the parameter value. BUT,
Is there a way to work around it so it does not ask me is its ok to update the table? How can i let it just do it without asking to update the table?

Thank you for your reply and help!
Dec 26 '10 #5
RuralGuy
375 Expert 256MB
Instead of
DoCmd.RunSQL SQL
...use
CurrentDB.Execute SQL, dbFailOnError
Dec 26 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: simon | last post by:
Hi I know this has been done to death....but obviously at some point in the dim and distant past! I wish to program a retail database for my shop, I have trawled many forums and I only manage...
12
by: Scott | last post by:
Front-end Access 2000 I have a stored procedure that has 2 parameters BusinessUnitID and Year. It returns multiple record sets (5 to be exact). I thought I could use a Pass through query but...
13
by: royaltiger | last post by:
I am trying to copy the inventory database in Building Access Applications by John L Viescas but when i try to run the database i get an error in the orders form when i click on the allocate...
3
by: brm6546545 | last post by:
I have a tblTax. It has fields InvoiceNum, TaxAuthority, TaxableTotal, NonTaxableTotal, TaxCollected. Sample data 1,county,10.00,0.00,0.40 1,city,10.00,0.00,0.10 2,state,0.00,15.00,0.15 ...
0
by: arichardson | last post by:
Hi...I need to insert some inventory items from a windows-form application. I have three tables: InventoryInvoice ( records the invoice number and maintains a row ID that is the primary key),...
1
by: starcandy | last post by:
haii........ ,first at all sorry because im not good in english i want to ask how to add quantity for inventory system .this is my form but it has error... <?php...
8
by: Ben | last post by:
Hi! I already sent this to the ACCESS newsgroup. But since I do not know really which side is really causing the problem, I have decided to send this inquiry to this newsgroup also, if I may....
4
by: Kliot | last post by:
I am trying to update a master inventory table from an order details table, the query below works fine except when the order details table contains the same code number multiple times. When this...
0
TonFrere
by: TonFrere | last post by:
Hello, I'm building a windows form application in Visual C# using VS 2005. On my form I need to populate a combobox with Invoices# linked to the current reccord's Order# value. This means that: -...
2
by: Jeganath | last post by:
Hi, I have written a Stored Procedure. I'm getting the error as below. Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32). Can any one give me a solution...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.