Passing Calendar DateClicked Variable

jstevens
GoldLounger
Posts: 2628
Joined: 26 Jan 2010, 16:31
Location: Southern California

Passing Calendar DateClicked Variable

Post by jstevens »

I'm having a challenge passing the DateClicked from a calendar in a UserForm and passing it to a text box in the form. The challenge is with a From and To date and passing the variable to their respective text boxes.

UserForm1.CommandButton1 = "From" uses UserForm1.Textbox1
UserForm1.CommandButton2 = "To" uses UserForm1.Textbox2
Public strDate

Step 1) Click on UserForm1.CommandButton1 to show the calendar form

Code: Select all

Sub CommandButton1()
   CalendarForm.Show
      UserForm1.Textbox1 = strDate    'This is where the challenge is with passing the variable
End Sub
Step 2). In the Private Sub MonthView1_DateCick(ByVal DateClicked As Date)

Code: Select all

'declare a variable strDate
strDate = DateClicked
Unload CalendarForm
Any assistance would be appreciated,
John
Regards,
John

User avatar
HansV
Administrator
Posts: 78401
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Passing Calendar DateClicked Variable

Post by HansV »

Declare strDate as a public variable in a standard module (not in either of the userform modules):

Public strDate
Best wishes,
Hans

jstevens
GoldLounger
Posts: 2628
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Passing Calendar DateClicked Variable

Post by jstevens »

Hans,

That did it.

Regards,
John
Regards,
John