Hi All,
I've been working on a User Form to track inventory and other items. One entry has me stumped and I cannot get it to function. The first operation is to have a Unique ID that will increase by 1 when the UserForm is opened. I'm using the following code, but cannot get it to work.
There is a TextBox that's named ID with the following code associated with that TextBox.
The code used for the Save button, which saves the form.
I'll need help to correct this code to have it increase automatically.
The second part, I would like for this unique ID to auto populate the ID textbox and be locked to the end user so that they cannot alter that number, but have it save to the file once the save button is clicked.
Any help would be greatly appreciated.
Craig
I've been working on a User Form to track inventory and other items. One entry has me stumped and I cannot get it to function. The first operation is to have a Unique ID that will increase by 1 when the UserForm is opened. I'm using the following code, but cannot get it to work.
There is a TextBox that's named ID with the following code associated with that TextBox.
Code:
''This increases the ID in the form.
'
Private Sub ID_Change()
Range("ID").Value = Range("ID").Value + 1
End Sub
The code used for the Save button, which saves the form.
Code:
Private Sub cmbSaveInv_Click() Dim lRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Asset List")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.ID.Value
.Cells(lRow, 2).Value = Me.cboxCategory.Value
.Cells(lRow, 3).Value = Me.Manufacturer.Value
.Cells(lRow, 4).Value = Me.cboxIvnType.Value
.Cells(lRow, 5).Value = Me.RRAbv.Value
.Cells(lRow, 6).Value = Me.RR.Value
.Cells(lRow, 7).Value = Me.RNumber.Value
.Cells(lRow, 8).Value = Me.Description.Value
.Cells(lRow, 9).Value = Me.cboxCondition.Value
.Cells(lRow, 10).Value = Me.AcquiredDate.Value
.Cells(lRow, 11).Value = Me.MfgDate.Value
.Cells(lRow, 12).Value = Me.RDate.Value
.Cells(lRow, 13).Value = Me.PurchasePrice.Value
.Cells(lRow, 14).Value = Me.MSRP.Value
.Cells(lRow, 15).Value = Me.CurrentValue.Value
.Cells(lRow, 16).Value = Me.cboxLocation.Value
.Cells(lRow, 17).Value = Me.InventoryNotes.Value
End With
I'll need help to correct this code to have it increase automatically.
The second part, I would like for this unique ID to auto populate the ID textbox and be locked to the end user so that they cannot alter that number, but have it save to the file once the save button is clicked.
Any help would be greatly appreciated.
Craig