pop-up placement - calendar

G

Guest

I have a calendar object on my form for the start and end dates, so I want
the calendar to be in different locations depending on which date is being
selected - how can I control the location of the pop-up depending on the
field being changed?
 
H

HKComputer

Here's how I would do that.

Make textbox on your form that has the visible property set to no.
Call it txtHidden1.

And lets just say your calendar is named Calendar1.

You probably have several date text boxes. Lets use this as an
example:

txtBeginDate
txtEndDate

Now, behind txtBeginDate Click Event, put this code:

Me.txtHidden1.Value = Me.txtBeginDate
Me.Calendar1.Left = 2
Me.Calendar1.Top = 3


Do the same for txtEndDate using Me.txtEndDate

On your Calendar's click event you should put: txtHidden1.value = ""

This worked for me. You will need to play with the Left and the Top
values to get it positioned where you want it. You can use decimals.

I use this code to make the calendar visible. I have it visible
property set to know in design view and set it back to false on a click
event.

Me.Calendar1.Visible = True
Me.Calendar1.Setfocus

Good Luck.
Let me know if it works or doesn't work
harlan dot koehn <at> gmail dot com
 
H

HKComputer

My above explanation left a few things out. Here is the code I used to
make it work for me:

Private Sub txtEndDate_Click()

Me.Calendar1.Visible = True
Me.Calendar1.Left = 9500
Me.Calendar1.Top = 2700
Me.Calendar1.Setfocus

End Sub
_________________________________________

Private Sub txtBeginDate_Click()

Me.txtHidden1.Value = "BD"
Me.Calendar1.Visible = True
Me.Calendar1.Left = 9500
Me.Calendar1.Top = 2700
Me.Calendar1.Setfocus

End Sub

_________________________________________

Private Sub Calendar1_Click()

If Me.txtHidden1.Value = "BD" Then
Me.txtBeginDate.Value = Me.Calendar1.Value
Me.txtBeginDate.Setfocus
Else
Me.txtEndDate.Value = Me.Calendar1.Value
Me.txtEndDate.Setfocus
End If

Me.Calendar1.Visible = False
Me.txtHidden1.Value = ""

End Sub



The location of the calendar (Top and Left) is in twips. Thats why the
numbers are so big. There is a way to use inches but right now I was
having trouble getting it into inches.


Good luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top