Calendar ActiveX control 9.0

G

Guest

Here is my problem :

There are 2 text box (date type) on my form that trigger a calendar control.
(with click event) After date selection, the date will be return to the
textbox that add called it.

Is there a way to let know to the calendar witch textbox is calling it ? I
don't want a create a calendar form for every control that will trigger a
calendar.

Yanick
 
N

Nikos Yannacopoulos

Yanick,

I understand the calendar control is on a separate form, opened by the click
event of the text boxes, right? I'll assume the following names in my
example, and you'll have to change to the eal ones:

Form with calendar: frmCalendar
Calendar control: ActiveXctl1

Right now, (part of) the code behind the click event of the text boxes must
look something like:

stDocName = "frmCalendar"
DoCmd.OpenForm stDocName, , , stLinkCriteria

change to:
ctrl = Me.Name & "*" & Me.ActiveControl.Name
stDocName = "frmCalendar"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , ctrl

This way, you are passing the form and control names separated by a * as an
opening argument to frmCalendar.

The code behind the click event of the calendar should be something like:

sep = InStr(1, OpenArgs, "*")
frm = Left(OpenArgs, sep - 1)
ctl = Right(OpenArgs, Len(OpenArgs) - sep)
Forms(frm).Controls(ctl) = Me.ActiveXctl1

This will work with different forms as well!

HTH,
Nikos
 
G

Guest

Incredible! I didn't know you can pass criteria to a form this way. I was
searching around something like "me.parent" but access doesn't seems to work
la that.

It is working well, thank you very much. Like we can say in Québec,Canada :
Complètement malade! Merci!

Yanick
 

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