Calendar/Text box problem

Neville Bentley

Board Regular
Joined
Oct 3, 2007
Messages
101
Hi out there,

Can any one help me please. I have a command button that a user can click on to enter a date from a Calendar control.
What I am expecting is that when the date is chosen in the calendar, to paste that value into the DateText box and I keep getting a "Compile error" Variable not defined and it highlights DateText.Value, where am I going wrong?

Private Sub cmbCalendar_Click()
frmCalendar.Show
If DateText.Value = "" Then
DateText.Value = Calendar1.Value
End If
End Sub

Cheers

Neville
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi there Andrew,

Thanks for replying so quickly.
The DateText is a text box in my userform.
With it being unqualified does default to the frmCalendar? So I must tell the code to put it into the userform, is that why I get that error?

Cheers

Neville
 
Upvote 0
Maybe it should be:

Code:
Private Sub cmbCalendar_Click()
    frmCalendar.Show
    If DateText.Value = "" Then
        DateText.Value = frmCalendar.Calendar1.Value
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top