473,403 Members | 2,366 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,403 software developers and data experts.

How to deduct sold item from quantity in access database. VB6.0

1
am developing a project point of sales in VB6.0. I need a code to deduct the sold item from the data base . each time they make sale it will automatically deduct from the quantity in the database and also show stock level is low when the item quantity in the database is less than 10. i have 18 items in the database. my code could only work for one item it doesn't work for the rest .
Thanks.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdsave_Click()
  2. Dim sql As String
  3. For i = 0 To List1.ListCount
  4. rstRecordSet.Open "INSERT INTO Salesrecord VALUES ('" & List1.List(i) & "', '" & List2.List(i) & "', '" & List3.List(i) & "','" & List4.List(i) & "','" & Text1.Text & "')", conConnection
  5.    Next i
  6.    MsgBox ("Record Added")
  7. sql = "update Stock set productquantity = productquantity - " & TxtQty.Text & "   where id =  'F0001'"""
  8. sql = "UPDATE Stock SET Productquantity =   productquantity  - " & TxtQty.Text & "   WHERE ProductID = 'F0002 '"
  9.  
  10. If productQuantity <= 10 Then
  11. MsgBox ("Stock Level is Low")
  12.  
  13. conConnection.Execute sql
  14.  
  15. End If
  16. End Sub
Attached Files
File Type: docx Private Sub cmdsave.docx (10.4 KB, 774 views)
Feb 21 '13 #1
1 7345
Mikkeee
94 64KB
Instead of using the recordset to insert use your connection.
Expand|Select|Wrap|Line Numbers
  1. For i = 0 To List1.ListCount
  2.    conConnection.Execute "INSERT INTO Salesrecord VALUES ('" & List1.List(i) & "', '" & List2.List(i) & "', '" & List3.List(i) & "','" & List4.List(i) & "','" & Text1.Text & "')"
  3. Next i
  4.  
Feb 24 '13 #2

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

Similar topics

0
by: marko | last post by:
Hi all! I'm trying to make a access database for my fathers shop and I'm pretty stuck so if anyone could help me that would mean a great deal for me! I would like to make a database in wich the...
0
by: RSH | last post by:
I am writing an app to extract Access database schemas. The issue is that while I have everything working, I am having trouble decyphering the returned values with regards to the column values. ...
2
by: Cary | last post by:
This may reveal my poor programming skills, but here goes... I'm building a pricing tool for my business. I'm nearing the end of the project, and I've been asked to be able to save quotes in some...
2
by: Stephen E. Weber | last post by:
I have an access database with an "item number" and a filespec for a JPG with the image for the item and a filespec for a HTM document with the description and specifications. I use a List Box and...
12
by: Matt.W.Stephens | last post by:
Here is the scenario. We have a database with patient case information. This database was previously solely used in Access. The problem is our users connect to this database (located in California)...
1
by: luvkling | last post by:
hi, i am new to asp.net. i currently doin a website. i created a add form in this form the user need to add in the record n when they press the submit button it will add the record into the access...
2
by: cday119 | last post by:
Can someone help me out with this one. I am trying to insert a row of data into an access database. The primary key is set to auto increment. It will work once but the next time you try an insert...
1
by: arvindmishra | last post by:
i m inserting values in access database it displays message value is inserted but value is not ptresent in database. I m using following code OleDbConnection cnn = new OleDbConnection(); ...
2
by: George Yar | last post by:
Re: How to show changes in open Access 2003 Table in VB I have a form to add a new record to my Access Database table. This is a code: Private Sub btnAdd_Click() Dim dbExpenses As...
0
by: NormanB | last post by:
I have a bound Access database which contains tables "Recipes", "Ingredients" and "Units". A linked table "Recipe ingredients" holds id references to each of these tables. My problem occurs when...
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
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...
0
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,...

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.