0% found this document useful (0 votes)
7 views

Codes

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Codes

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

CODES

MODULE: INVENTORY

Sub Reset()

Dim iRow As Long

iRow = [Counta(Database!A:A)] ' identifying the last row

With frmForm

.txtNameofproduct.Value = ""

.txtPriceperproduct.Value = "'"

.txtQuantitysold.Value = ""

.cmbConsignesname.Clear

.cmbConsignesname.AddItem "Name1"

.cmbConsignesname.AddItem "Name2"

.cmbConsignesname.AddItem "Name3"

.cmbConsignesname.AddItem "Name4"

.txtIncome.Value = ""

.txt10.Value = ""

.lstDatabase.ColumnCount = 9

.lstDatabase.ColumnHeads = True
.lstDatabase.ColumnWidths = "40,80,80,80,70,50,30,50,40"

If iRow > 1 Then

.lstDatabase.RowSource = "DATABASE!A2:I" & iRow

Else

.lstDatabase.RowSource = "DATABASE!A2:I2"

End If

End With

End Sub

Sub Submit()

Dim sh As Worksheet

Dim iRow As Long

Set sh = ThisWorkbook.Sheets("DATABASE")

iRow = [Counta(Database!A:A)] + 1

With sh

.Cells(iRow, 1) = iRow - 1

.Cells(iRow, 2) = frmForm.txtNameofproduct.Value

.Cells(iRow, 3) = frmForm.txtPriceperproduct.Value
.Cells(iRow, 4) = frmForm.txtQuantitysold.Value

.Cells(iRow, 5) = frmForm.cmbConsignesname.Value

.Cells(iRow, 6) = frmForm.txtIncome.Value

.Cells(iRow, 7) = frmForm.txt10.Value

.Cells(iRow, 8) = Application.UserName

.Cells(iRow, 9) = [Text(Now(), "DD-MM-YYYY HH:MM:SS")]

End With

End Sub

Sub Show_FormfrmForm()

frmForm.Show

End Sub

BUTTONS: FRMFORM

Private Sub cmdReset_Click()

Dim msgValue As VbMsgBoxResult

msgValue = MsgBox("Do you want to reset the form?", vbYesNo + vbInformation, "Confirmation")
If msgValue = vbNo Then Exit Sub

Call Reset

End Sub

Private Sub cmdSave_Click()

Dim msgValue As VbMsgBoxResult

msgValue = MsgBox("Do you want to save the data?", vbYesNo + vbInformation, "Confirmation")

If msgValue = vbNo Then Exit Sub

Call Submit

Call Reset

End Sub

Private Sub UserFormfrmForm_Initialize()

Call Reset

End Sub

You might also like