View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
David Macdonald David Macdonald is offline
external usenet poster
 
Posts: 26
Default different dates from one calendar

Nick,
A million thanks! This also gets rid of the button too.
There was only one advantage I could see to my method - after putting the
date into the right textbox the cursor would go to the next field (as set up
in tab order) but now it always goes to the beginning of the form. There's
something for me to work on this morning...


"NickHK" wrote:

David,
The userform has an ActiveControl property, but in your case, this would be
the calendar not the text box.
You could give yourself a private object the track the destination textbox,
setting it when each tb is entered. Then the calendar (I've used a listbox
here, but the same applies) sends it's value to that tb:

Dim mtb As msforms.TextBox

Private Sub ListBox1_Click()
mtb.Value = ListBox1.Value
End Sub

Private Sub TextBox1_Enter()
Set mtb = TextBox1
End Sub

Private Sub TextBox2_Enter()
Set mtb = TextBox2
End Sub

NickHK

"David Macdonald" wrote in
message ...
I've got my form with TextBoxes and I've got my calendar.
I've even got the thing loading all the necessary fields into the right
cells in a new correctly formatted row on my worksheet.
All of this thanks to posts I found here - I've learnt so much in the last

2
weeks!

Three of the textboxes on this form need to take dates. How can I tell the
Calendar which of the three to send the data to ?
My solution:
Three separate calendars (and CommandButtons to send the Value) that only
become visible when the cursor enters the relative textbox. i.e. Calendar1
appears when entering TextBox1 then disappears after its button is

clicked,
Calendar2 appears later on when entering TextBox2 etc. I could place them

all
in the same position so to the user it'd look like the same calendar
appearing each time. I certainly don't want three calendars filling my

form!

Is there a more direct way ? Some property of textBoxes like "HasFocus" or
"IsActive" that I could use ?