Delete the three rows in your post#15
paste the code below over the existing 'ADD' sub.
Private Sub cmdADD_Click()
If Me.Reg1 = "" Then
MsgBox ("No Refrence Number Entered"), vbOKOnly + vbInformation, "Error"
Me.Reg1.SetFocus
Exit Sub
End If
sc = Me.ComboBox1.ListCount + 1
chk = Me.Reg1.Value
Set ws = Sheet2
Set tbl = ws.ListObjects("Table1")
With tbl
For m = 1 To sc
If .Range(m, 1) = chk Then
response = MsgBox("Duplicate Item Number - Is this a different " & chk & " ?", vbYesNo, "Duplicate")
If response = vbNo Then
ClearForm
Exit Sub
End If
End If
Next m
Application.ScreenUpdating = False
Set newrow = tbl.ListRows.Add
With newrow
For x = 1 To 28
.Range(x) = Me("Reg" & x).Value
Next x
'**************************** additional code ********************
If IsDate(Controls("Reg3").Text) Then
.Range(3) = DateValue(Controls("Reg3").Text)
Else
.Range(3) = ""
End If
If IsDate(Controls("Reg4").Text) Then
.Range(4) = DateValue(Controls("Reg4").Text)
Else
.Range(4) = ""
End If
If IsDate(Controls("Reg14").Text) Then
.Range(14) = DateValue(Controls("Reg14").Text)
Else
.Range(14) = ""
End If
'****************************************************************
End With
End With
Set sortcolumn = Range("Table1[Full Name]")
With tbl.Sort
.SortFields.Clear
.SortFields.Add Key:=sortcolumn, SortOn:=xlSortOnValues, Order:=xlAscending
.Header = xlYes
.Apply
End With
ClearForm
LoadComboBox
Application.ScreenUpdating = True
MsgBox ("Details Saved"), vbOKOnly + vbInformation, "SAVED"
End Sub
Format the three date columns as per format in clip.
Format the complete columns - not just the table content - the format needs to be in place ready to receive added data.
Attachment 703116
Bookmarks