Hi All,
I have a worksheet with a command button that opens an Excel form named frmMain.
On that form I have a frame named fraMain that has a textbox named txtDate. (The first field on the form)
I'm trying to get the current Date to populate the textbox automatically while also allowing the user to enter in a different date if needed. This is what I've tried all the following in the form VBA but no date shows up on the form load:<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: inherit;">
</code>Can somebody point out what I am doing wrong? I realize I only need on function but I can't get any to work. Thanks!
I have a worksheet with a command button that opens an Excel form named frmMain.
On that form I have a frame named fraMain that has a textbox named txtDate. (The first field on the form)
I'm trying to get the current Date to populate the textbox automatically while also allowing the user to enter in a different date if needed. This is what I've tried all the following in the form VBA but no date shows up on the form load:<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: inherit;">
Code:
[COLOR=#101094][FONT=Verdana][FONT=Consolas]Private Sub frmMain_Activate()[/FONT][/FONT]
txtDate.text = Format(Now(),"MM/DD/YY")
End Sub
[/COLOR][COLOR=#101094][FONT=Verdana][FONT=Consolas]
Private Sub frmMain_Initialize()[/FONT][/FONT][/COLOR]
[COLOR=#101094] me.txtDate.text = Format(Now(),"MM/DD/YY")[/COLOR]
[COLOR=#101094]End Sub[/COLOR]
[COLOR=#101094]
Private Sub fraMain_txtDate_Activate()
If Me.txtDate.Value = "" Then
Me.txtDate.Value = Format(Date, "dd/mm/yyyy")
End If
End Sub
Private Sub fraMain_Initialize()
If Me.ActiveControl.ActiveControl.Name = "txtDate" Then
Me.txtDate.Value = Format(Date, "dd/mm/yyyy")
End If
[/COLOR]
</code>Can somebody point out what I am doing wrong? I realize I only need on function but I can't get any to work. Thanks!