The document contains code for an inventory management system with forms for stock and sales. The stock form code handles adding, updating, deleting, and searching stock records. The sales form code handles adding sales records, updating the stock records, and searching, navigating, and displaying sales records. Functions are used to move data between the sales and stock records and clear form fields.
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
99 views
Code
The document contains code for an inventory management system with forms for stock and sales. The stock form code handles adding, updating, deleting, and searching stock records. The sales form code handles adding sales records, updating the stock records, and searching, navigating, and displaying sales records. Functions are used to move data between the sales and stock records and clear form fields.
If (rs.EOF = True) Then rs.AddNew rs("pcode") = Val(Text1.Text) rs("pname") = Text2.Text rs("totalstock") = Val(Text3.Text) rs.Update MsgBox "Record Inserted", vbExclamation, "Inventory System" Else avail_stock = rs("totalstock") rs("totalstock") = avail_stock + Val(Text3.Text) rs.Update MsgBox "Record updated", vbExclamation, "Inventory System" End If Text1.Text = "" Text2.Text = "" Text3.Text = "" End Sub Private Sub Command2_Click() rs("pcode") = Val(Text1.Text) rs("pname") = Text2.Text rs("totalstock") = Val(Text3.Text) rs.Update MsgBox "Record updated", vbExclamation, "Inventory System" End Sub
Private Sub Command3_Click()
rs.Delete Text1.Text = "" Text2.Text = "" Text3.Text = "" MsgBox "Record deleted", vbExclamation, "Inventory System" End Sub
Private Sub Command4_Click()
Dim product_code product_code = InputBox("Enter the product code", "Inventory system") rs.Find "pcode=" & product_code, , adSearchForward, 1 If (rs.EOF = True) Then MsgBox "Record Not Found", vbCritical, "Inventory System" Else Text1.Text = rs("pcode") Text2.Text = rs("pname") Text3.Text = rs("totalstock") End If End Sub
Private Sub Command5_Click()
rs.MoveNext If (rs.EOF = True) Then MsgBox "End of File Reached" rs.MoveLast Else Text1.Text = rs("pcode") Text2.Text = rs("pname") Text3.Text = rs("totalstock") End If
End Sub
Private Sub Command6_Click()
rs.MovePrevious If (rs.BOF = True) Then MsgBox "Begining of File Reached" rs.MoveFirst Else Text1.Text = rs("pcode") Text2.Text = rs("pname") Text3.Text = rs("totalstock") End If End Sub
Private Sub Command7_Click()
rs.MoveFirst Text1.Text = rs("pcode") Text2.Text = rs("pname") Text3.Text = rs("totalstock") End Sub
Private Sub Command8_Click()
rs.MoveLast Text1.Text = rs("pcode") Text2.Text = rs("pname") Text3.Text = rs("totalstock") End Sub
Private Sub Command9_Click()
Unload Me Form1.Show End Sub
************************** CODE FOR SALES FORM ************************** Private Sub Command1_Click() Dim avail_stock As Integer, total_stock As Integer
stockrs.Find "pcode=" & Text2.Text
If (stockrs.EOF = True) Then MsgBox "Productcode Not Found", vbCritical, "Inventory System" Else total_stock = stockrs("totalstock") avail_stock = total_stock - Val(Text4.Text) If (avail_stock <= 0) Then MsgBox "Insufficient stock", vbCritical, "Inventory System" Text4.SetFocus Else salesrs.AddNew Call move_data2salestable salesrs.Update MsgBox "Record Inserted into sales table", vbExclamation, "Inventory System"
'the following code update the stock table
stockrs("totalstock") = avail_stock stockrs.Update MsgBox "Stock table updated", vbExclamation, "Inventory System" Call clearformfields End If End If End Sub Public Sub clearformfields() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text6.Text = "" End Sub
Private Sub Command2_Click()
Call move_data2salestable salesrs.Update MsgBox "Record Updated", vbExclamation, "Inventory System" End Sub
Dim customerid customerid = InputBox("Enter the Customer_id", "Inventory system") salesrs.Find "Customer_id=" & customerid, , adSearchForward, 1 If (salesrs.EOF = True) Then MsgBox "Record Not Found", vbCritical, "Inventory System" Else Call display_sales_record End If End Sub
Private Sub Command5_Click()
salesrs.MoveNext If (salesrs.EOF = True) Then MsgBox "End of File Reached" salesrs.MoveLast Else Call display_sales_record End If End Sub
Private Sub Command6_Click()
salesrs.MovePrevious If (salesrs.BOF = True) Then MsgBox "Begining of File Reached" salesrs.MoveFirst Else Call display_sales_record End If End Sub