473,698 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

updating QTY on Hand when you make a new sale

this is my code, it is updating QTY on Hand when you make a new sale or

if you got some product returned. Now as it is updating QTY when qty
textbox lost focus if some one is going through records and whenever
this qty text box will losee focus it will be fired and change the
quantity in the product table. I want it, to be fired only ig user
clicks qty text box or only if new record is inserted.Can you help.
Private Sub qty_Click()
On Error GoTo Err_qty_Click
Dim TotalQty As Integer
TotalQty = 0
Product = Forms![frmSale]![tblSaleDetail*]![Product]
TotalQty = DLookup("[QtyOnHand]", "[Products]", "[ProductID]=" &
Product)
If (TotalQty - [qty]) < 1 Then
MsgBox "Inventory Below 0. Quantity Issued is To High!"
Exit Sub
End If
TotalQty = TotalQty + [qty]
DoCmd.SetWarnin gs False
DoCmd.RunSQL "UPDATE [Products] SET " & _
" [Products].[QtyOnHand] = " & TotalQty & _
" WHERE [Products].[ProductID] =" & [Product]
DoCmd.SetWarnin gs True
Exit_qty_Click:
Exit Sub
Err_qty_Click:
MsgBox Err.Description
Resume Exit_qty_Click
End Sub
Private Sub qty_LostFocus()
On Error GoTo Err_qty_LostFoc us
Dim TotalQty As Integer
TotalQty = 0
Product = Forms![frmSale]![tblSaleDetail*]![Product]
TotalQty = DLookup("[QtyOnHand]", "[Products]", "[ProductID]=" &
Product)
If (TotalQty - [qty]) < 1 Then
MsgBox "Inventory Below 0. Quantity Issued is To High!"
Exit Sub
End If
TotalQty = TotalQty - [qty]
DoCmd.SetWarnin gs False
DoCmd.RunSQL "UPDATE [Products] SET " & _
" [Products].[QtyOnHand] = " & TotalQty & _
" WHERE [Products].[ProductID] =" & [Product]
DoCmd.SetWarnin gs True
Me.subtotal = Me.qty * Me.SalePrice
Exit_qty_LostFo cus:
Exit Sub
Err_qty_LostFoc us:
MsgBox Err.Description
Resume Exit_qty_LostFo cus
End Sub

Nov 13 '05 #1
5 1643
"khan" <ah******@gmail .com> schreef in bericht

<everything snipped>

Check out:
http://www.allenbrowne.com/AppInventory.html

Btw:
I could swear I saw an identical message from you some hour ago.
Please try to be a bit more patient...

Arno R
Nov 13 '05 #2
"Arno R" <ar***********@ tiscali.nl> wrote in message
news:42******** *************@d reader2.news.ti scali.nl...
"khan" <ah******@gmail .com> schreef in bericht

<everything snipped>

Check out:
http://www.allenbrowne.com/AppInventory.html

Btw:
I could swear I saw an identical message from you some hour ago.
Please try to be a bit more patient...

Arno R
This guy is obviously too busy to check out external links. He does not
seem to be looking for a deeper understanding of Access, just some geeky
nerd who will re-write his code for free... and wait ... someone probably
will.
Nov 13 '05 #3
thanks

Nov 13 '05 #4

"Arno R" <ar***********@ tiscali.nl> wrote in message
news:42******** *************@d reader2.news.ti scali.nl...
"khan" <ah******@gmail .com> schreef in bericht

<everything snipped>

Check out:
http://www.allenbrowne.com/AppInventory.html

Btw:
I could swear I saw an identical message from you some hour ago.
Please try to be a bit more patient...

Arno R

This is the same guy that repeatedly posted the same message last week. The
"r u crazy" and "I swear to god" guy. He's doing it again.

Nov 13 '05 #5

"Randy Harris" <ra***@SpamFree .com> schreef in bericht news:9Y******** *******@newssvr 19.news.prodigy .com...

This is the same guy that repeatedly posted the same message last week. The
"r u crazy" and "I swear to god" guy. He's doing it again.


Hi Randy,
I did recognize him ... I was just trying the 'more friendly' approach.

BUT, nothing works I guess, since he just posted the question for the third time... <sigh>
I was thinking someone is making a joke, but (checked headers) it seems to be the same person.

Arno R

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
16195
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? 1) simply UPDATING the values for all fields in the table, whether or not any particular field has actually changed 2) running a second SELECT statement and comparing the $_POST vars to the returned values, and only UPDATING those that have...
45
2667
by: It's me | last post by:
I am new to the Python language. How do I do something like this: I know that a = 3 y = "a" print eval(y)
3
2783
by: Robin Tucker | last post by:
Hi there, I have a database on my test machine that will need to be installed on users machines. I would like to create the database with the given schema on the users machine and also with some suitable default values in the tables. I note that although I can script the schema so that re-creating the structure of the database is simple on the users machine, I cannot script the contents of the tables also (automatically). What I would...
11
26321
by: Randell D. | last post by:
Folks, I have seven text boxes which will contain measurements - I would like the user to input their values in the order that I have listed the boxes. How can I therefore make an input type=text name=box2 a readonly while type=text name=box1 has a length of zero? This is for an intranet based application and I understand all the arguements and points that one has to consider in such that my server
0
1298
by: cwbp17 | last post by:
Have two tables that have a FK relationship on ID column. Have one datagrid that displays all of the columns of both tables. What's the best approach on updating a row from the datagrid back to the database? I've used the following code for the DataGird1_UpdateCommand Option1
15
2661
by: Colin | last post by:
I have a query that calculates the selling price of products on customer orders. Selling prices are calculated based on the average cost of the items when purchased. As I make new purchases, the product cost changes (as it should) to reflect the new average cost. However, the problem is that the selling price of previously sold items also change when new purchases are made. Keep in mind that I'm not storing any calculated values anywhere....
3
1477
by: paolo_maldini | last post by:
Hello everyone,,, Here is my problem, I'm using MS Access, I'm building a mobile inventory system.I have a table (Products) and I want to update the Quantity of mobiles each time I perform a sale operation. Sales operations are performed through a Form(Invoice) and in that form I built a subform-that was built using a query- where most of the sale details are specified. However, I don't know how I can subtract the quantity entered in the...
4
2695
by: Mark Olbert | last post by:
I've written a composite custom control which I would like to have update its design-time display when one of several properties changes at design time. These custom properties are not simply the exposed properties of the constituent controls (e.g., they control how many constitutent controls are displayed). I am at a loss as to how to go about doing this. I have a custom designer for the control, but I don't see any functionality in the...
18
1972
omerbutt
by: omerbutt | last post by:
AJAX PROB WITH MULTIPLE RECORDS helo iam having problem in ma code will any body look out an help, i am trying t add sale record in the database and the checkthe quantity of the part slod and decrement it to the current quantity for example if tehre is a part woth part no 10023 and its quantity in show room is 20 and total quantity is 25 then if there is a sale of 2 parts then i have to add the sale and decrement the current quantity in the...
0
8674
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9023
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7721
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4615
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.