View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
access user access user is offline
external usenet poster
 
Posts: 32
Default How to Pass a date from a calendar control to a field on a for

Hi

Yes the three text boxes for the dates are on the same form as the calendar.
Your code below works.

However, I think you replied just as I posed my additional question. So now,
if I want the date to go into whichever box has currently got the focus then
how would you do that?

tia
James

"Dave Peterson" wrote:

Is txtPeriodFrom a textbox on that same form?

Me.txtPeriodFrom.Value = Format(Calendar1.Value, "mmmm dd, yyyy")

I still like to qualify my objects.

If this doesn't help, it's time to share more details.

What is txtPeriodFrom?
Is the calendar control part of the same userform?



access user wrote:

in my code please ignore the first section as it is headed with ' (I was just
trying that out). So the code I am using and that does not work is:

Me.txtPeriodFrom.ControlSource = Format(Calendar1.Value, "mmmm dd, yyyy")

tia
James

"access user" wrote:

Hi

Thanks for your response, however it does not work. I have the following code:

Private Sub EnterDate()
'Me.txtPeriodFrom.ControlSource =
Worksheets("InputDataEntry").Range("A1").Value
Me.txtPeriodFrom.ControlSource = Format(Calendar1.Value, "mmmm dd, yyyy")
End Sub

Where I have "ControlSource" is where you had "caption" in your suggestion.
Caption was not recognised.

Any other suggestions?

tia
James

"Dave Peterson" wrote:

Maybe something like:

Me.label1.caption = format(calendar1.value,"mmmm dd, yyyy")


access user wrote:

Hi

I have followed the link that RondeBruin gives to this site

http://www.fontstuff.com/vba/vbatut07.htm

which shows how to add a calendar control. However I want to pass the date
from the calendar to a field on a form (the calendar and field in question
are both on the same form). The info on the above link only shows how to pass
it to an active cell on the worksheet.

Would appreciate any help.

tia
James

--

Dave Peterson


--

Dave Peterson