Two pretty much identical text boxes, "Start Date *" and "Start Date"
http://i.imgur.com/946Fspr.png
The date is typed into those two text boxes which are named 'txtStartdat1' and 'txtStartdat2' respectively.
I type in the date "01/02/03" for example and when I press save, it saves that date as "01/02/03" in the correct cell on the worksheet.
However, when I go back into my userform to update incorrect information, I use my 'Update' button instead of the save button.
The difference between the two is one saves to a new line, the other saves over old information.
It is the 'Update' button that is saving the date wrong. The information is coming from the same text boxes but I don't know how to fit the code into my update button to make it format the date correctly.
This is the code I am currently using for my 'Update' button, specifically "txtStartdat1" and "txtStartdat2" are the ones that need formatting.
Private Sub cmbUpdate_Click()
Dim answer As Integer
answer = MsgBox("Please use 'Save' if entering a new Contract, this feature is for correcting mistakes in data entry.", vbYesNo + vbQuestion, "Are you sure you want to Update?")
If answer = vbYes Then
Cost As String, Deposit As String, Start1 As String, PaymentL1 As String, PaymentP1 As String, Amount1 As String, Start2 As String, PaymentL2 As String
Cost = txtCost.Value
Cells(currentrow, 17).Value = Cost
Deposit = txtDeposit.Value
Cells(currentrow, 18).Value = Deposit
Start1 = txtStartdat1.Text
Cells(currentrow, 21).Value = Start1
PaymentL1 = txtPayment1.Text
Cells(currentrow, 22).Value = PaymentL1
PaymentP1 = cbxPayment1.Text
Cells(currentrow, 24).Value = PaymentP1
Amount1 = txtAmount1.Value
Cells(currentrow, 25).Value = Amount1
Start2 = txtStartdat2.Text
Cells(currentrow, 26).Value = Start2
PaymentL2 = txtPayment2.Text
Cells(currentrow, 27).Value = PaymentL2
Else
'do nothing
End If
End Sub
As for the code I used, I tried entering:
Start1 = CDate(txtStartdat1.Text)
Cells(currentrow, 21).Value = Start1
That into my 'Update' button. It didn't change the date format.
Bookmarks