Hi.
I have a User Form to add information in a data list.
In some of the textboxes, I want the information to be added to the list in a certain format.
For example:
1. the engine model to be all in UPPER CASE
2. the manufacturer to be in Proper Case, unless user entered all information in upper case
3. the in service date to be in the format "yyyy-mm-dd" It would also be nice if the user only have to enter 2 digits for the year and not have to enter the seperator.)
I've done some research, but can't seem to find the answer.
my Code so far is:
I have a User Form to add information in a data list.
In some of the textboxes, I want the information to be added to the list in a certain format.
For example:
1. the engine model to be all in UPPER CASE
2. the manufacturer to be in Proper Case, unless user entered all information in upper case
3. the in service date to be in the format "yyyy-mm-dd" It would also be nice if the user only have to enter 2 digits for the year and not have to enter the seperator.)
I've done some research, but can't seem to find the answer.
my Code so far is:
Code:
Private Sub btAdd_Click()
Dim r As Long
'did user input correctly
If Me.tbESN = VBA.Constants.vbNullString Then
MsgBox "Please input a Engine Serial Number."
Me.tbESN.SetFocus
Exit Sub
End If
If Me.tbEModel = VBA.Constants.vbNullString Then
MsgBox "Please input a Engine Model."
Me.tbEModel.SetFocus
Exit Sub
End If
If IsNumeric(Me.tbESN) = False Then
MsgBox "Please input a valid number."
Me.tbESN.SetFocus
Exit Sub
End If
' If IsNumeric(Me.tbCPL) = False Then
' MsgBox "Please input a valid number."
' Me.tbCPL.SetFocus
' Exit Sub
' End If
With Engine_Information
'find the last row
r = .Range("A" & .Rows.Count).End(xlUp).Row + 1
.Range("A" & r).Value = Val(Me.tbESN) ' Number format (8 digits only)
.Range("B" & r).Value = UCase(tbEModel.Value) ' UPPER CASE
.Range("C" & r).Value = Proper(tbMnftr.Value) ' Proper Case
.Range("D" & r).Value = Proper(tbMnftrModel.Value) ' Proper Case
.Range("E" & r).Value = Val(Me.tbCPL) ' Number (4 digits only
.Range("F" & r).Value = tbInServiceDate ' Date format (yyyy-mm-dd)
.Range("G" & r).Value = UCase(tbFno.Value)
.Range("H" & r).Value = UCase(Me.tbRegNo.Value)
.Range("I" & r).Value = UCase(Me.TbChassis.Value)
.Range("J" & r).Value = UCase(Me.tbEngCtrl.Value)
.Range("K" & r).Value = Proper(Me.tbSiteAddr1.Value)
.Range("L" & r).Value = Proper(Me.tbSiteAddr2.Value)
' Me.tbCustomer = ""
' Me.tbValue = ""
End With
Unload Me
End Sub