Hello,
i am not very literate in VBA but through google i managed to make a database style worksheet for my sister to record inventory stock.
What i cannot figure out now is the selection of date.
When we click NEW STOCK then there are some fields to complete. Is there a way to have also a field with now date to be automatically added?
For now the person should select from the drop down list the date, but i dont mind either if the date is automatically put there, or if the date is automatically put the other sheet where the data is stored.
If in the end the date is selected from the list, is there a way to show the actual date on the form after is selected, rather than just numbers?
The code for now is like this:
Private Sub EntertheData_Click()
Dim RowCount As Long
Dim ctl As Control
' Chexk user input
If Me.Quantity.Value = "" Then
MsgBox "Please enter the quantity if shoes", vbExclamation, "Staff Expenses"
Me.Quantity.SetFocus
Exit Sub
End If
' Write data to worksheet
RowCount = Worksheets("Sale").Range("B1").CurrentRegion.Rows.Count
With Worksheets("Sale").Range("B1")
.Offset(RowCount, 1).Value = Me.Quantity.Value
.Offset(RowCount, 2).Value = Me.Shoes.Value
.Offset(RowCount, 3).Value = Me.Size.Value
.Offset(RowCount, 4).Value = Me.Number.Value
.Offset(RowCount, 5).Value = Me.DateNow.Value
End With
' Clear the form
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
ctl.Value = ""
ElseIf TypeName(ctl) = "CheckBox" Then
ctl.Value = False
End If
Next ctl
End Sub
i am not very literate in VBA but through google i managed to make a database style worksheet for my sister to record inventory stock.
What i cannot figure out now is the selection of date.
When we click NEW STOCK then there are some fields to complete. Is there a way to have also a field with now date to be automatically added?
For now the person should select from the drop down list the date, but i dont mind either if the date is automatically put there, or if the date is automatically put the other sheet where the data is stored.
If in the end the date is selected from the list, is there a way to show the actual date on the form after is selected, rather than just numbers?
The code for now is like this:
Private Sub EntertheData_Click()
Dim RowCount As Long
Dim ctl As Control
' Chexk user input
If Me.Quantity.Value = "" Then
MsgBox "Please enter the quantity if shoes", vbExclamation, "Staff Expenses"
Me.Quantity.SetFocus
Exit Sub
End If
' Write data to worksheet
RowCount = Worksheets("Sale").Range("B1").CurrentRegion.Rows.Count
With Worksheets("Sale").Range("B1")
.Offset(RowCount, 1).Value = Me.Quantity.Value
.Offset(RowCount, 2).Value = Me.Shoes.Value
.Offset(RowCount, 3).Value = Me.Size.Value
.Offset(RowCount, 4).Value = Me.Number.Value
.Offset(RowCount, 5).Value = Me.DateNow.Value
End With
' Clear the form
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
ctl.Value = ""
ElseIf TypeName(ctl) = "CheckBox" Then
ctl.Value = False
End If
Next ctl
End Sub