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

Order Form

The document contains Visual Basic code for forms and macros related to a customer/order management system. It includes code for forms to add new customers, products, suppliers, and receive orders. It also includes event handler subroutines for buttons on these forms to add/validate data and populate fields. The code inserts new rows into Excel sheets when data is added and looks up product details from a data range.

Uploaded by

Kunal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
191 views

Order Form

The document contains Visual Basic code for forms and macros related to a customer/order management system. It includes code for forms to add new customers, products, suppliers, and receive orders. It also includes event handler subroutines for buttons on these forms to add/validate data and populate fields. The code inserts new rows into Excel sheets when data is added and looks up product details from a data range.

Uploaded by

Kunal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 22

-----------------------------------New Customer----------------------------------------Private Sub cmdClose_Click()

Unload Me
End Sub
----------------------------------------------------------------------------Private Sub cmdCustomer_Click()
Dim X As Integer
Dim nextrow As Range
On Error GoTo cmdCustomer_Click_Error
Set nextrow = Sheet6.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0)
For X = 1 To 4
If Me.Controls("Customer" & X).Value = "" Then
MsgBox "You must add Name ,Address ,City and State"
Exit Sub
End If
Next
If WorksheetFunction.CountIf(Sheet6.Range("C:C"), Me.Customer1.Value) > 0 Then
MsgBox "This customer already exists"
Exit Sub
End If
For X = 1 To 9
nextrow = Me.Controls("Customer" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
'clear
For X = 1 To 9
Me.Controls("Customer" & X).Value = ""
Next
On Error GoTo 0
Exit Sub
cmdCustomer_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdCusto
mer_Click of Form frmCustomer"
End Sub
---------------------------------Main Form Menu------------------------------------------Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdCustomer_Click()
NewShowCustomer
End Sub
Private Sub cmdNewProduct_Click()

NewProductShow
End Sub
Private Sub cmdOrders_Click()
NewOrderShow
End Sub
Private Sub cmdReceiving_Click()
ReceivingShow
End Sub
Private Sub cmdVendor_Click()
NewVendorShow
End Sub
-------------------------------------------Add New Product-----------------------------------------------------------------Private Sub cmdAddProduct_Click()
Dim X As Integer
Dim nextrow As Range
On Error GoTo cmdAddProduct_Click_Error
Set nextrow = Sheet5.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0)
For X = 1 To 6
If Me.Controls("Product" & X).Value = "" Then
MsgBox "Missing data"
Exit Sub
End If
Next
If WorksheetFunction.CountIf(Sheet5.Range("E:E"), Me.Product4.Value) > 0 Then
MsgBox "This product code already exists"
Exit Sub
End If
If WorksheetFunction.CountIf(Sheet5.Range("L:L"), Me.Product2.Value) = 0 Then
Select Case MsgBox("This is a new category. It will now be added to the category
list.." _
& vbCrLf & "Are you sure that you want to proceed?" _
, vbYesNo Or vbQuestion Or vbDefaultButton1, "Please check this first")
Case vbYes
Case vbNo
Exit Sub
End Select
Sheet5.Cells(Rows.Count, 12).End(xlUp).Offset(1, 0) = Me.Product2.Value
End If
For X = 1 To 6
nextrow = Me.Controls("Product" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
'clear
For X = 1 To 6
Me.Controls("Product" & X).Value = ""
Next
Sortit

On Error GoTo 0
Exit Sub
cmdAddProduct_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdAddPr
oduct_Click of Form frmNewProduct"
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
--------------------------------------------------Supplier-----------------------------------------------------------------------------------Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdSupplier_Click()
Dim X As Integer
Dim nextrow As Range
On Error GoTo cmdSupplier_Click_Error
Set nextrow = Sheet4.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0)
For X = 1 To 9
If Me.Controls("Vendor" & X).Value = "" Then
MsgBox "Missing data"
Exit Sub
End If
Next
If WorksheetFunction.CountIf(Sheet4.Range("C:C"), Me.Vendor1.Value) > 0 Then
MsgBox "This Supplier already exists"
Exit Sub
End If
For X = 1 To 9
nextrow = Me.Controls("Vendor" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
'clear
For X = 1 To 9
Me.Controls("Vendor" & X).Value = ""
Next
On Error GoTo 0
Exit Sub
cmdSupplier_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdSuppl
ier_Click of Form frmVendor"
End Sub
-----------------------------------------Receiving----------------------------------------------------------------------------------------Private Sub cmdReceiving_Click()
Dim X As Integer
Dim nextrow As Range
Dim DateCus As Range
On Error GoTo cmdOrders_Click_Error

Me.Arec6.Value
Me.Brec6.Value
Me.Crec6.Value
Me.Drec6.Value
Me.Erec6.Value
Me.Frec6.Value

=
=
=
=
=
=

Format(Me.Arec6.Value,
Format(Me.Brec6.Value,
Format(Me.Crec6.Value,
Format(Me.Drec6.Value,
Format(Me.Erec6.Value,
Format(Me.Frec6.Value,

"$##,###.00")
"$##,###.00")
"$##,###.00")
"$##,###.00")
"$##,###.00")
"$##,###.00")

If Me.cboReceiving.Value = "" Or Me.txtONum.Value = "" Or Me.txtDate.Value = ""


Or Me.Arec1.Value = "" Then
MsgBox "No data in Stock"
Exit Sub
Else
Set nextrow = Sheet3.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0)
If Arec1.Value > "" Then
For X = 1 To 6
nextrow = Me.Controls("Arec" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
SetmeRec
Set nextrow = Sheet3.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0)
If Brec1.Value > "" Then
For X = 1 To 6
nextrow = Me.Controls("Brec" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
SetmeRec
Set nextrow = Sheet3.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0)
If Crec1.Value > "" Then
For X = 1 To 6
nextrow = Me.Controls("Crec" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
SetmeRec
Set nextrow = Sheet3.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0)
If Drec1.Value > "" Then
For X = 1 To 6
nextrow = Me.Controls("Drec" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
SetmeRec
Set nextrow = Sheet3.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0)
If Erec1.Value > "" Then
For X = 1 To 6
nextrow = Me.Controls("Erec" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
SetmeRec
Set nextrow = Sheet3.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0)
If Frec1.Value > "" Then
For X = 1 To 6
nextrow = Me.Controls("Frec" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If

SetmeRec
Recieved
Unload Me
frmReceiving.Show
End If
On Error GoTo 0
Exit Sub
cmdOrders_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdOrder
s_Click of Form frmReceiving"
End Sub
Private Sub crec1_Change()
Dim X As Integer
On Error Resume Next
If Me.Brec3 = "" Then
MsgBox "You must fill in the previous row"
Me.Crec1.Value = ""
Exit Sub
Else
Sheet5.Range("M6").Value = Me.Crec1.Value
Adv
For X = 2 To 6
Me.Controls("Crec" & X).Value = ""
Next
Me.Crec2.RowSource = "Product"
End If
On Error GoTo 0
End Sub
Private Sub Drec1_Change()
Dim X As Integer
On Error Resume Next
If Me.Crec3 = "" Then
MsgBox "You must fill in the previous row"
Me.Drec1.Value = ""
Exit Sub
Else
Sheet5.Range("M6").Value = Me.Drec1.Value
Adv
For X = 2 To 6
Me.Controls("Drec" & X).Value = ""
Next
Me.Drec2.RowSource = "Product"
End If
On Error GoTo 0
End Sub

Private Sub Erec1_Change()


Dim X As Integer
On Error Resume Next
If Me.Drec3 = "" Then
MsgBox "You must fill in the previous row"
Me.Erec1.Value = ""
Exit Sub
Else
Sheet5.Range("M6").Value = Me.Erec1.Value
Adv
For X = 2 To 6
Me.Controls("Erec" & X).Value = ""
Next
Me.Erec2.RowSource = "Product"
End If
On Error GoTo 0
End Sub
Private Sub Frec1_Change()
Dim X As Integer
On Error Resume Next
If Me.Erec3 = "" Then
MsgBox "You must fill in the previous row"
Me.Frec1.Value = ""
Exit Sub
Else
Sheet5.Range("M6").Value = Me.Frec1.Value
Adv
For X = 2 To 6
Me.Controls("Frec" & X).Value = ""
Next
Me.Frec2.RowSource = "Product"
End If
On Error GoTo 0
End Sub
Private Sub Arec3_Change()
On Error Resume Next
Me.Arec2.RowSource = ""
Me.Arec4 = Application.WorksheetFunction.VLookup(Me.Arec2, Sheet5.Range("Data"),
2, 0)
Me.Arec5 = Application.WorksheetFunction.VLookup(Me.Arec2, Sheet5.Range("Data"),
3, 0)
If Me.Arec3.Value > "" Then Me.Arec6 = Me.Arec3.Value * Me.Arec5.Value
On Error GoTo 0
End Sub

Private Sub Brec3_Change()


On Error Resume Next
Me.Brec2.RowSource = ""
Me.Brec4 = Application.WorksheetFunction.VLookup(Me.Brec2, Sheet5.Range("Data"),
2, 0)
Me.Brec5 = Application.WorksheetFunction.VLookup(Me.Brec2, Sheet5.Range("Data"),
3, 0)
If Me.Brec3.Value > "" Then Me.Brec6 = Me.Brec3.Value * Me.Brec5.Value
On Error GoTo 0
End Sub
Private Sub Crec3_Change()
On Error Resume Next
Me.Crec2.RowSource = ""
Me.Crec4 = Application.WorksheetFunction.VLookup(Me.Crec2, Sheet5.Range("Data"),
2, 0)
Me.Crec5 = Application.WorksheetFunction.VLookup(Me.Crec2, Sheet5.Range("Data"),
3, 0)
If Me.Crec3.Value > "" Then Me.Crec6 = Me.Crec3.Value * Me.Crec5.Value
On Error GoTo 0
End Sub
Private Sub Drec3_Change()
On Error Resume Next
Me.Drec2.RowSource = ""
Me.Drec4 = Application.WorksheetFunction.VLookup(Me.Drec2, Sheet5.Range("Data"),
2, 0)
Me.Drec5 = Application.WorksheetFunction.VLookup(Me.Drec2, Sheet5.Range("Data"),
3, 0)
If Me.Drec3.Value > "" Then Me.Drec6 = Me.Drec3.Value * Me.Drec5.Value
On Error GoTo 0
End Sub
Private Sub Erec3_Change()
On Error Resume Next
Me.Erec2.RowSource = ""
Me.Erec4 = Application.WorksheetFunction.VLookup(Me.Erec2, Sheet5.Range("Data"),
2, 0)
Me.Erec5 = Application.WorksheetFunction.VLookup(Me.Erec2, Sheet5.Range("Data"),
3, 0)
If Me.Erec3.Value > "" Then Me.Erec6 = Me.Erec3.Value * Me.Erec5.Value
On Error GoTo 0
End Sub
Private Sub Frec3_Change()
On Error Resume Next
Me.Frec2.RowSource = ""
Me.Frec4 = Application.WorksheetFunction.VLookup(Me.Frec2, Sheet5.Range("Data"),
2, 0)
Me.Frec5 = Application.WorksheetFunction.VLookup(Me.Frec2, Sheet5.Range("Data"),

3, 0)
If Me.Frec3.Value > "" Then Me.Frec6 = Me.Frec3.Value * Me.Frec5.Value
On Error GoTo 0
End Sub
Sub SetmeRec()
Dim DateCus As Range
On Error GoTo SetmeRec_Error
Set DateCus = Sheet3.Cells(Rows.Count, 6).End(xlUp).Offset(0, -1)
DateCus = Val(Me.txtONum)
DateCus.Offset(0, -1) = Me.cboReceiving
DateCus.Offset(0, -2) = Format(Me.txtDate.Value, "d/m/yyyy")
On Error GoTo 0
Exit Sub
SetmeRec_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure SetmeRec
of Form frmReceiving"
End Sub
--------------------------------------------Orders------------------------------------------------------------------------------------------Private Sub cmdOrders_Click()
Dim X As Integer
Dim nextrow As Range
Dim DateCus As Range
On Error GoTo cmdOrders_Click_Error
Me.Arow7.Value
Me.Brow7.Value
Me.Crow7.Value
Me.Drow7.Value
Me.Erow7.Value
Me.Frow7.Value
Me.Grow7.Value
Me.Hrow7.Value
Me.Irow7.Value
Me.Jrow7.Value

=
=
=
=
=
=
=
=
=
=

Format(Me.Arow7.Value,
Format(Me.Brow7.Value,
Format(Me.Crow7.Value,
Format(Me.Drow7.Value,
Format(Me.Erow7.Value,
Format(Me.Frow7.Value,
Format(Me.Grow7.Value,
Format(Me.Hrow7.Value,
Format(Me.Irow7.Value,
Format(Me.Jrow7.Value,

"$##,###.00")
"$##,###.00")
"$##,###.00")
"$##,###.00")
"$##,###.00")
"$##,###.00")
"$##,###.00")
"$##,###.00")
"$##,###.00")
"$##,###.00")

Select Case MsgBox("Please check all of the information before submitting", _


vbYesNo Or vbQuestion Or vbDefaultButton1, "Please check your entry")
Case vbYes
Case vbNo
Exit Sub
End Select
If Me.cboCustomer.Value = "" Or Me.txtONum.Value = "" Or Me.txtDate.Value = "" O
r Me.Arow1.Value = "" Then
MsgBox "Incomplete data"
Exit Sub
Else
Set nextrow = Sheet2.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0)
If Me.Arow1.Value > "" Then
For X = 1 To 7
nextrow = Me.Controls("Arow" & X).Value
Set nextrow = nextrow.Offset(0, 1)

Next
End If
Setme
Set nextrow = Sheet2.Cells(Rows.Count, 6).End(xlUp).Offset(1,
If Me.Brow1.Value > "" Then
For X = 1 To 7
nextrow = Me.Controls("Brow" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
Setme
Set nextrow = Sheet2.Cells(Rows.Count, 6).End(xlUp).Offset(1,
If Me.Crow1.Value > "" Then
For X = 1 To 7
nextrow = Me.Controls("Crow" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
Setme
Set nextrow = Sheet2.Cells(Rows.Count, 6).End(xlUp).Offset(1,
If Me.Drow1.Value > "" Then
For X = 1 To 7
nextrow = Me.Controls("Drow" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
Setme
Set nextrow = Sheet2.Cells(Rows.Count, 6).End(xlUp).Offset(1,
If Me.Erow1.Value > "" Then
For X = 1 To 7
nextrow = Me.Controls("Erow" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
Setme
Set nextrow = Sheet2.Cells(Rows.Count, 6).End(xlUp).Offset(1,
If Me.Frow1.Value > "" Then
For X = 1 To 7
nextrow = Me.Controls("Frow" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
Setme
Set nextrow = Sheet2.Cells(Rows.Count, 6).End(xlUp).Offset(1,
If Me.Grow1.Value > "" Then
For X = 1 To 7
nextrow = Me.Controls("Grow" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
Setme
Set nextrow = Sheet2.Cells(Rows.Count, 6).End(xlUp).Offset(1,
If Me.Hrow1.Value > "" Then
For X = 1 To 7
nextrow = Me.Controls("Hrow" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
Setme
Set nextrow = Sheet2.Cells(Rows.Count, 6).End(xlUp).Offset(1,

0)

0)

0)

0)

0)

0)

0)

0)

If Me.Irow1.Value > "" Then


For X = 1 To 7
nextrow = Me.Controls("Irow" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
Setme
Set nextrow = Sheet2.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0)
If Me.Jrow1.Value > "" Then
For X = 1 To 7
nextrow = Me.Controls("Jrow" & X).Value
Set nextrow = nextrow.Offset(0, 1)
Next
End If
Setme
Ordered
Unload Me
frmOrders.Show
End If
On Error GoTo 0
Exit Sub
cmdOrders_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdOrder
s_Click of Form frmOrders"
End Sub
Private Sub Arow1_Change()
Dim X As Integer
On Error Resume Next
Sheet5.Range("M6").Value = Me.Arow1.Value
Adv
For X = 2 To 7
Me.Controls("Arow" & X).Value = ""
Next
Me.Arow2.RowSource = "Product"
On Error GoTo 0
End Sub
Private Sub Brow1_Change()
Dim X As Integer
On Error Resume Next
If Me.Arow3 = "" Then
MsgBox "You must fill in the previous row"
Me.Brow1.Value = ""
Exit Sub
Else
Sheet5.Range("M6").Value = Me.Brow1.Value
Adv
For X = 2 To 7
Me.Controls("Brow" & X).Value = ""
Next
Me.Brow2.RowSource = "Product"
End If
On Error GoTo 0
End Sub

Private Sub Crow1_Change()


Dim X As Integer
On Error Resume Next
If Me.Brow3 = "" Then
MsgBox "You must fill in the previous row"
Me.Crow1.Value = ""
Exit Sub
Else
Sheet5.Range("M6").Value = Me.Crow1.Value
Adv
For X = 2 To 7
Me.Controls("Crow" & X).Value = ""
Next
Me.Crow2.RowSource = "Product"
End If
On Error GoTo 0
End Sub
Private Sub Drow1_Change()
Dim X As Integer
On Error Resume Next
If Me.Crow3 = "" Then
MsgBox "You must fill in the previous row"
Me.Drow1.Value = ""
Exit Sub
Else
Sheet5.Range("M6").Value = Me.Drow1.Value
Adv
For X = 2 To 7
Me.Controls("Drow" & X).Value = ""
Next
Me.Drow2.RowSource = "Product"
End If
On Error GoTo 0
End Sub
Private Sub Erow1_Change()
Dim X As Integer
On Error Resume Next
If Me.Drow3 = "" Then
MsgBox "You must fill in the previous row"
Me.Erow1.Value = ""
Exit Sub
Else
Sheet5.Range("M6").Value = Me.Erow1.Value
Adv
For X = 2 To 7
Me.Controls("Erow" & X).Value = ""
Next
Me.Erow2.RowSource = "Product"
End If
On Error GoTo 0
End Sub
Private Sub Frow1_Change()
Dim X As Integer

On Error Resume Next


If Me.Erow3 = "" Then
MsgBox "You must fill in the previous row"
Me.Frow1.Value = ""
Exit Sub
Else
Sheet5.Range("M6").Value = Me.Frow1.Value
Adv
For X = 2 To 7
Me.Controls("Frow" & X).Value = ""
Next
Me.Frow2.RowSource = "Product"
End If
On Error GoTo 0
End Sub
Private Sub Grow1_Change()
Dim X As Integer
On Error Resume Next
If Me.Frow3 = "" Then
MsgBox "You must fill in the previous row"
Me.Grow1.Value = ""
Exit Sub
Else
Sheet5.Range("M6").Value = Me.Grow1.Value
Adv
For X = 2 To 7
Me.Controls("Grow" & X).Value = ""
Next
Me.Grow2.RowSource = "Product"
End If
On Error GoTo 0
End Sub
Private Sub Hrow1_Change()
Dim X As Integer
On Error Resume Next
If Me.Grow3 = "" Then
MsgBox "You must fill in the previous row"
Me.Hrow1.Value = ""
Exit Sub
Else
Sheet5.Range("M6").Value = Me.Hrow1.Value
Adv
For X = 2 To 7
Me.Controls("Hrow" & X).Value = ""
Next
Me.Hrow2.RowSource = "Product"
End If
On Error GoTo 0
End Sub
Private Sub Irow1_Change()
Dim X As Integer

On Error Resume Next


If Me.Hrow3 = "" Then
MsgBox "You must fill in the previous row"
Me.Irow1.Value = ""
Exit Sub
Else
Sheet5.Range("M6").Value = Me.Irow1.Value
Adv
For X = 2 To 7
Me.Controls("Irow" & X).Value = ""
Next
Me.Irow2.RowSource = "Product"
End If
On Error GoTo 0
End Sub
Private Sub Jrow1_Change()
Dim X As Integer
On Error Resume Next
If Me.Irow3 = "" Then
MsgBox "You must fill in the previous row"
Me.Jrow1.Value = ""
Exit Sub
Else
Sheet5.Range("M6").Value = Me.Jrow1.Value
Adv
For X = 2 To 7
Me.Controls("Jrow" & X).Value = ""
Next
Me.Jrow2.RowSource = "Product"
End If
On Error GoTo 0
End Sub
Private Sub Arow3_Change()
On Error Resume Next
Me.Arow2.RowSource = ""
Me.Arow4 = Application.WorksheetFunction.VLookup(Me.Arow2, Sheet5.Range("Data"),
2, 0)
Me.Arow6 = Application.WorksheetFunction.VLookup(Me.Arow2, Sheet5.Range("Data"),
4, 0)
Me.Arow5 = Application.WorksheetFunction.VLookup(Me.Arow2, Sheet5.Range("Data"),
6, 0)
If Me.Arow3.Value > "" Then Me.Arow7 = Me.Arow3.Value * Me.Arow6.Value
On Error GoTo 0
End Sub
Private Sub Brow3_Change()
On Error Resume Next
Me.Brow2.RowSource = ""
Me.Brow4 = Application.WorksheetFunction.VLookup(Me.Brow2, Sheet5.Range("Data"),
2, 0)
Me.Brow6 = Application.WorksheetFunction.VLookup(Me.Brow2, Sheet5.Range("Data"),
4, 0)

Me.Brow5 = Application.WorksheetFunction.VLookup(Me.Brow2, Sheet5.Range("Data"),


6, 0)
If Me.Brow3.Value > "" Then Me.Brow7 = Me.Brow3.Value * Me.Brow6.Value
On Error GoTo 0
End Sub
Private Sub Crow3_Change()
On Error Resume Next
Me.Crow2.RowSource = ""
Me.Crow4 = Application.WorksheetFunction.VLookup(Me.Crow2, Sheet5.Range("Data"),
2, 0)
Me.Crow6 = Application.WorksheetFunction.VLookup(Me.Crow2, Sheet5.Range("Data"),
4, 0)
Me.Crow5 = Application.WorksheetFunction.VLookup(Me.Crow2, Sheet5.Range("Data"),
6, 0)
If Me.Crow3.Value > "" Then Me.Crow7 = Me.Crow3.Value * Me.Crow6.Value
On Error GoTo 0
End Sub
Private Sub Drow3_Change()
On Error Resume Next
Me.Drow2.RowSource = ""
Me.Drow4 = Application.WorksheetFunction.VLookup(Me.Drow2, Sheet5.Range("Data"),
2, 0)
Me.Drow6 = Application.WorksheetFunction.VLookup(Me.Drow2, Sheet5.Range("Data"),
4, 0)
Me.Drow5 = Application.WorksheetFunction.VLookup(Me.Drow2, Sheet5.Range("Data"),
6, 0)
If Me.Drow3.Value > "" Then Me.Drow7 = Me.Drow3.Value * Me.Drow6.Value
On Error GoTo 0
End Sub
Private Sub Erow3_Change()
On Error Resume Next
Me.Erow2.RowSource = ""
Me.Erow4 = Application.WorksheetFunction.VLookup(Me.Erow2, Sheet5.Range("Data"),
2, 0)
Me.Erow6 = Application.WorksheetFunction.VLookup(Me.Erow2, Sheet5.Range("Data"),
4, 0)
Me.Erow5 = Application.WorksheetFunction.VLookup(Me.Erow2, Sheet5.Range("Data"),
6, 0)
If Me.Erow3.Value > "" Then Me.Erow7 = Me.Erow3.Value * Me.Erow6.Value
On Error GoTo 0
End Sub
Private Sub Frow3_Change()
On Error Resume Next
Me.Frow2.RowSource = ""
Me.Frow4 = Application.WorksheetFunction.VLookup(Me.Frow2, Sheet5.Range("Data"),
2, 0)
Me.Frow6 = Application.WorksheetFunction.VLookup(Me.Frow2, Sheet5.Range("Data"),
4, 0)
Me.Frow5 = Application.WorksheetFunction.VLookup(Me.Frow2, Sheet5.Range("Data"),
6, 0)

If Me.Frow3.Value > "" Then Me.Frow7 = Me.Frow3.Value * Me.Frow6.Value


On Error GoTo 0
End Sub
Private Sub Grow3_Change()
On Error Resume Next
Me.Grow2.RowSource = ""
Me.Grow4 = Application.WorksheetFunction.VLookup(Me.Grow2, Sheet5.Range("Data"),
2, 0)
Me.Grow6 = Application.WorksheetFunction.VLookup(Me.Grow2, Sheet5.Range("Data"),
4, 0)
Me.Grow5 = Application.WorksheetFunction.VLookup(Me.Grow2, Sheet5.Range("Data"),
6, 0)
If Me.Grow3.Value > "" Then Me.Grow7 = Me.Grow3.Value * Me.Grow6.Value
On Error GoTo 0
End Sub
Private Sub Hrow3_Change()
On Error Resume Next
Me.Hrow2.RowSource = ""
Me.Hrow4 = Application.WorksheetFunction.VLookup(Me.Hrow2, Sheet5.Range("Data"),
2, 0)
Me.Hrow6 = Application.WorksheetFunction.VLookup(Me.Hrow2, Sheet5.Range("Data"),
4, 0)
Me.Hrow5 = Application.WorksheetFunction.VLookup(Me.Hrow2, Sheet5.Range("Data"),
6, 0)
If Me.Hrow3.Value > "" Then Me.Hrow7 = Me.Hrow3.Value * Me.Hrow6.Value
On Error GoTo 0
End Sub
Private Sub Irow3_Change()
On Error Resume Next
Me.Irow2.RowSource = ""
Me.Irow4 = Application.WorksheetFunction.VLookup(Me.Irow2, Sheet5.Range("Data"),
2, 0)
Me.Irow6 = Application.WorksheetFunction.VLookup(Me.Irow2, Sheet5.Range("Data"),
4, 0)
Me.Irow5 = Application.WorksheetFunction.VLookup(Me.Irow2, Sheet5.Range("Data"),
6, 0)
If Me.Irow3.Value > "" Then Me.Irow7 = Me.Irow3.Value * Me.Irow6.Value
On Error GoTo 0
End Sub
Private Sub Jrow3_Change()
On Error Resume Next
Me.Jrow2.RowSource = ""
Me.Jrow4 = Application.WorksheetFunction.VLookup(Me.Jrow2, Sheet5.Range("Data"),
2, 0)
Me.Jrow6 = Application.WorksheetFunction.VLookup(Me.Jrow2, Sheet5.Range("Data"),
4, 0)
Me.Jrow5 = Application.WorksheetFunction.VLookup(Me.Jrow2, Sheet5.Range("Data"),
6, 0)
If Me.Jrow3.Value > "" Then Me.Jrow7 = Me.Jrow3.Value * Me.Jrow6.Value
On Error GoTo 0
End Sub

Sub Setme()
Dim DateCus As Range
On Error GoTo Setme_Error
Set DateCus = Sheet2.Cells(Rows.Count, 6).End(xlUp).Offset(0, -1)
DateCus = Val(Me.txtONum)
DateCus.Offset(0, -1) = Me.cboCustomer
DateCus.Offset(0, -2) = Format(Me.txtDate.Value, "d/m/yyyy")
On Error GoTo 0
Exit Sub
Setme_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Setme of
Form frmOrders"
End Sub
---------------------------------------------------Assorted----------------------------------------------------------------------------Sub NewVendorShow()
On Error GoTo NewVendorShow_Error
If frmVendor.Visible = True Then
Unload frmVendor
Else
frmVendor.Show
End If
On Error GoTo 0
Exit Sub
NewVendorShow_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure NewVendo
rShow of Module Assorted"
End Sub
Sub NewShowCustomer()
On Error GoTo NewShowCustomer_Error
If frmCustomer.Visible = True Then
Unload frmCustomer
Else
frmCustomer.Show
End If
On Error GoTo 0
Exit Sub
NewShowCustomer_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure NewShowC
ustomer of Module Assorted"
End Sub
Sub NewProductShow()
On Error GoTo NewProductShow_Error
If frmNEwProduct.Visible = True Then

Unload frmNEwProduct
Else
frmNEwProduct.Show
End If
On Error GoTo 0
Exit Sub
NewProductShow_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure NewProdu
ctShow of Module Assorted"
End Sub
Sub Sortit()
On Error GoTo Sortit_Error
Application.ScreenUpdating = False
returnto = ActiveSheet.Name
Sheet5.Activate
With Sheet5
Sheet5.Range("B6:G10000").Sort Key1:=Range("C5"), Order1:=xlAscending, Header:=x
lGuess
End With
ThisWorkbook.Sheets(returnto).Select
On Error GoTo 0
Exit Sub
Sortit_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Sort
it of Module Assorted"
End Sub
Sub ReceivingShow()
On Error GoTo ReceivingShow_Error
If frmReceiving.Visible = True Then
Unload frmReceiving
Else
frmReceiving.Show
End If
On Error GoTo 0
Exit Sub
ReceivingShow_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Receivin
gShowof Module Assorted"
End Sub
Sub Adv()
On Error GoTo Adv_Error
Sheet5.Range("Cat_Full").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=She
et5.Range( _
"M5:M6"), CopyToRange:=Sheet5.Range("N5:O5"), Unique:=False
On Error GoTo 0

Exit Sub
Adv_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Adv of M
odule Assorted"
End Sub

Sub Recieved()
On Error GoTo Recieved_Error
Dim returnto
Application.ScreenUpdating = False
returnto = ActiveSheet.Name
Sheet3.Activate
With Sheet3
Sheet3.Range("G6:G" & Cells(Rows.Count, "G").End(xlUp).Row).Name = "AllReceived"
Sheet3.Range("H6:H" & Cells(Rows.Count, "H").End(xlUp).Row).Name = "RecievedTot"
End With
ThisWorkbook.Sheets(returnto).Select
On Error GoTo 0
Exit Sub
Recieved_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Recieved
of Module Assorted"
End Sub

Sub Ordered()
On Error GoTo Ordered_Error
Application.ScreenUpdating = False
returnto = ActiveSheet.Name
Sheet2.Activate
With Sheet2
.Range("G6:L" & Cells(Rows.Count, "G").End(xlUp).Row).Name = "Items"
.Range("G6:G" & Cells(Rows.Count, "G").End(xlUp).Row).Name = "AllProducts"
.Range("H6:H" & Cells(Rows.Count, "H").End(xlUp).Row).Name = "AllOrdered"
End With
ThisWorkbook.Sheets(returnto).Select
On Error GoTo 0
Exit Sub
Ordered_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Ordered
of Module Assorted"
End Sub
Sub NewOrderShow()

On Error GoTo NewOrderShow_Error


If frmOrders.Visible = True Then
Unload frmOrders
Else
frmOrders.Show
End If
On Error GoTo 0
Exit Sub
NewOrderShow_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure NewOrder
Show of Module Assorted"
End Sub

Private Sub cmdClear_Click()


Unload Me
frmReceiving.Show
End Sub
Sub MenuShow()
On Error GoTo MenuShow_Error
If frmMenu.Visible = True Then
Unload frmMenu
Else
frmMenu.Show
End If
On Error GoTo 0
Exit Sub
MenuShow_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure MenuShow
of Module Assorted"
End Sub
=------------------------------------------------Filters Module-------------------------------------------------------------------------Sub AdvFilter()
Sheet2.Range("C5:L10000").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("AA7:AC8"), CopyToRange:=Range("L24:N24"), Unique:= _
False
If Range("N25") = "" Then
Range("L25") = "12/12/12"
Range("N25") = 0
End If
End Sub

=------------------------------------------------Filters Module-------------------------------------------------------------------------Sub AdvStock()


On Error GoTo AdvStock_Error
Application.ScreenUpdating = False
Unprotect_All
Sheet5.Range("C5:J1000").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheet1.Range("B20:C21"), CopyToRange:=Sheet1.Range("B24:I24"), Un
ique:= _
False
Sheet1.Select
Range("b26").Select
Protect_All
On Error GoTo 0
Exit Sub
AdvStock_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure AdvStock
of Module Filters"
End Sub
Sub AdvReorder()
On Error GoTo AdvReorder_Error
Application.ScreenUpdating = False
Unprotect_All
Sheet5.Range("C5:J1000").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheet1.Range("H20:H21"), CopyToRange:=Sheet1.Range("B24:I24"), Un
ique:= _
False
Sheet1.Select
Range("B26").Select
Protect_All
On Error GoTo 0
Exit Sub
AdvReorder_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure AdvReord
er of Module Filters"
End Sub
Sub Protect_All()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Protect Password:="Online", DrawingObjects:=True, Contents:=True, Scenarios:=
True _
, AllowFormattingCells:=True, AllowSorting:=True, Userinterfaceonly:=True
ActiveSheet.EnableSelection = xlUnlockedCells
Next ws
End Sub
Sub Unprotect_All()
Dim I

On Error Resume Next


For I = 1 To Sheets.Count
Sheets(I).Unprotect Password:="Online"
Next I
On Error GoTo 0
End Sub
Sub ClearData()
On Error GoTo ClearData_Error
Range("B25:I1000").ClearContents
On Error GoTo 0
Exit Sub
ClearData_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ClearDat
a of Module Filters"
End Sub

=------------------------------------------------Name Manager-------------------------------------------------------------------------Data
=OFFSET(Products!$D$6,,,COUNTA(Products!$D$6:$D$2000),6)
Extract
Date Customer Total
==Interface!$L$24:$N$24
Extract
Category Product
=Products!$N$5:$O$5
Items
==Orders!$G$6:$L$127
Product
==OFFSET(Products!$O$6,,,COUNTA(Products!$O$6:$O$10000))
ReceivedTot
=Recieving!$H$6:$H$14
Reorder
=OFFSET(Products!$J$6,,,COUNTA(Products!$J$6:$J$1000))
Suppliers
=OFFSET(Supplier!$C$6,,,COUNTA(Supplier!$C$6:$C$1000))
Customer
==OFFSET(Customers!$C$6,,,COUNTA(Customers!$C$6:$C$1000))
ChartTotal
==OFFSET(Interface!$N$25,,,COUNTA(Interface!$N$25:$N$1000))
ChartDate

==OFFSET(Interface!$L$25,,,COUNTA(Interface!$L$25:$L$1000))
Category
==OFFSET(Products!$L$6,,,COUNTA(Products!$L$6:$L$100))
Cat_Validation
=OFFSET(Products!$C$6,,,COUNTA(Products!$C$6:$C$10000))
Cat_full
=OFFSET(Products!$C$5,,,COUNTA(Products!$C$5:$C$20000),2)
Cascade
=Products!$D$5
AllReceived
=Recieving!$G$6:$G$14
AllProducts
=Orders!$G$6:$G$127
AllOrdered
=Orders!$H$6:$H$127

You might also like