Hi, I have designed a VBA form in Excel and when the user clicks on the add new record button I want it to populate another text box with todays date.
This below is my code I have used and it populates the textbox with a date but its an american style date. this is no good to me, how can I change it around for the british way?
Private Sub cmdAdd_Click()
lngLastRow = findLastRow(Sheets("ToSend").Range("A2"), "") + 1
Me.cmdAdd.Enabled = False
Me.txtInputDate = Now()
Me.txtInputBy = fOSUserName
End Sub
I then tried this that had used in Access before and all it did was put it the correct way but show as text numbers.
Private Sub cmdAdd_Click()
lngLastRow = findLastRow(Sheets("ToSend").Range("A2"), "") + 1
Me.cmdAdd.Enabled = False
Me.txtInputDate = Timer.timeSince("30/12/1899", VBA.DateTime.DateValue(VBA.DateTime.DateSerial(Yea r(usrFrmCustInput.CreateDate), Month(usrFrmCustInput.CreateDate), Day(usrFrmCustInput.CreateDate))))
Me.txtInputBy = fOSUserName
End Sub
Module Timer
Function timeSince(strDateFrom As String, strDateTo As String) As Double
If VBA.IsDate(strDateFrom) And VBA.IsDate(strDateTo) Then
Dim lngDays As Long
lngDays = VBA.DateDiff("d", strDateFrom, strDateTo, vbSunday)
timeSince = lngDays
Else
timeSince = 0
End If
End Function