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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Neville Bentley

Board Regular
Joined
Oct 3, 2007
Messages
101
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

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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,191,004
Messages
5,984,116
Members
439,872
Latest member
noaman79

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
Top