Your requirements are not entirely clear, but give these changes a try and let me know how it goes.
Form initialize code:
Private Sub UserForm_Initialize()
MultiPage1.Value = 0
Dim cUnique As Collection
Dim rng As Range
Dim cell As Range
Dim vNum As Variant
Dim i As Integer
Dim strW As String
Dim sh As Worksheet
Dim lastrow As Long
lastrow = Worksheets("Case Log").Range("A" & Rows.Count).End(xlUp).Offset(0).Row
If lastrow > 1 Then
Me.TextBox13.Value = "DVI-" & Format(Split(Cells(lastrow, "A"), "-")(1) + 1, "00000") & "-" & Format(1, "000")
Else
Me.TextBox13.Value = "DVI-" & Format(lastrow, "00000") & "-" & Format(lastrow, "000")
End If
Me.TextBox13.Enabled = False
...
...
Add button code:
Private Sub CommandButton12_Click()
TextBox16.MultiLine = True
With TextBox16
.Text = .Text & vbCr & TextBox13.Text & " " & ComboBox6.Text & " " & TextBox6.Text & " " & TextBox15.Text
End With
ComboBox6.ListIndex = -1
TextBox6.Text = vbNullString
TextBox15.Text = vbNullString
TextBox13.Value = "DVI-" & Format(Split(TextBox13.Value, "-")(1), "00000") & "-" & Format(Split(TextBox13.Value, "-")(2) + 1, "000")
End Sub
Prelog button code:
Private Sub CommandButton3_Click()
Dim iRow As Long
Dim ws As Worksheet
Dim myLines As Variant
Set ws = Worksheets("Case Log")
myLines = Split(TextBox16.Text, vbCr)
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.TextBox13.Text
ws.Cells(iRow, 2).Resize(1 + UBound(myLines), 1).Value = myLines
ws.Cells(iRow, 5).Value = Me.TextBox4.Text
TextBox13.Value = "DVI-" & Format(Split(TextBox13.Value, "-")(1) + 1, "00000") & "-" & Format(1, "000")
Me.TextBox14.Text = "NULL"
Me.TextBox14.Enabled = False
End Sub
Bookmarks