Use of "Parent"

G

Guest

Greetings.

I have an ActiveX Calendar control I use to set dates. I am now calling this
control from more than one form and have it transferring the graphically
selected dates back to text controls on the calling form. I have tried:

Forms.Parent.[DateIN] = Me.startdate
Forms.Parent.[DateOUT] = Me.enddate

I use [DateIN] and [DateOUT] on all the calling forms so the names of the
text controls are consistent. The Me.startdate and Me.enddate are the names
of the selected dates from the calendar form.

I get an error msg:

Run Time error 438

Object doesn't support this property or method.

I have also tried bracketing all the terms to no avail.

Am I on the wrong side of the road?
 
S

Stefan Hoffmann

hi,
Forms.Parent.[DateIN] = Me.startdate
I get an error msg:
Run Time error 438
Object doesn't support this property or method.
Try Me.Parent.Form.[DateIN] = Me.StartDate. Parent is a property of a
form, not of the Forms-collection.


mfG
--> stefan <--
 
G

Guest

Hi Stefan
No Go

I get

Run Time error 2452

the expression you entered has an invalid reference to the Parent property
--
GmH


Stefan Hoffmann said:
hi,
Forms.Parent.[DateIN] = Me.startdate
I get an error msg:
Run Time error 438
Object doesn't support this property or method.
Try Me.Parent.Form.[DateIN] = Me.StartDate. Parent is a property of a
form, not of the Forms-collection.


mfG
--> stefan <--
 
A

Amy Blankenship

Try putting this line just before your code:
debug.Print Me.Parent.Name

If you also put a break point right after that line, you can look in the
locals window and see what properties and collections belong to your current
object, including the Parent property and its collections.

HTH;

Amy

RoadKyng said:
Hi Stefan
No Go

I get

Run Time error 2452

the expression you entered has an invalid reference to the Parent property
--
GmH


Stefan Hoffmann said:
hi,
Forms.Parent.[DateIN] = Me.startdate
I get an error msg:
Run Time error 438
Object doesn't support this property or method.
Try Me.Parent.Form.[DateIN] = Me.StartDate. Parent is a property of a
form, not of the Forms-collection.


mfG
--> stefan <--
 
G

Guest

When you say from more than one form, are you on the sub form of the main
form, and accessing the main form? If that is the case, I would use
Me.Parent!DateOut

But, if you are on a completely differnt form, then the .Parent will not
work. In that case, I would use:
Forms!Mainform!DateOut

or if it is on a sub forme
Forms!Mainform!subform.Form!DateOut

HTH
 
G

Guest

What I mean is, I have made a form with a graphical calendar control and
unbound text boxes. The form is called DateSetter. (original eh?)

I have more than one reporting forms where date ranges are required. I want
to be able to call the DateSetter form to select the dates graphically then
transfer the values back to DateIN and DateOUT text boxes on the calling
reporting form. I have kept the names of the text boxes on these reporting
forms the same for consistency.

I thought I could call the form (datesetter) and use code to transfer the
values back to the calling form, and since there is more than one form that
could call DateSetter the method needs to be generic.

In essence, can VB be easily coded to know what form had the control that
opened the datesetter form, and transfer the needed values accordingly?




--
GmH


SteveInBeloit said:
When you say from more than one form, are you on the sub form of the main
form, and accessing the main form? If that is the case, I would use
Me.Parent!DateOut

But, if you are on a completely differnt form, then the .Parent will not
work. In that case, I would use:
Forms!Mainform!DateOut

or if it is on a sub forme
Forms!Mainform!subform.Form!DateOut

HTH


RoadKyng said:
Greetings.

I have an ActiveX Calendar control I use to set dates. I am now calling this
control from more than one form and have it transferring the graphically
selected dates back to text controls on the calling form. I have tried:

Forms.Parent.[DateIN] = Me.startdate
Forms.Parent.[DateOUT] = Me.enddate

I use [DateIN] and [DateOUT] on all the calling forms so the names of the
text controls are consistent. The Me.startdate and Me.enddate are the names
of the selected dates from the calendar form.

I get an error msg:

Run Time error 438

Object doesn't support this property or method.

I have also tried bracketing all the terms to no avail.

Am I on the wrong side of the road?
 
T

TC

RoadKyng said:
What I mean is, I have made a form with a graphical calendar control and
unbound text boxes. The form is called DateSetter. (original eh?)

I have more than one reporting forms where date ranges are required. I want
to be able to call the DateSetter form to select the dates graphically then
transfer the values back to DateIN and DateOUT text boxes on the calling
reporting form. I have kept the names of the text boxes on these reporting
forms the same for consistency.

I thought I could call the form (datesetter) and use code to transfer the
values back to the calling form, and since there is more than one form that
could call DateSetter the method needs to be generic.

In essence, can VB be easily coded to know what form had the control that
opened the datesetter form, and transfer the needed values accordingly?


I haven't read the whole thread, so take this FWIW.

You use Parent from a *subform* to refer to the calling form. You can't
use Parent when the two forms are only related by the fact that one of
them has opened the other one with DoCmd.OpenForm.

Two approaches you could use to return a value to the calling form.

(1) The calendar form could expect the calling (openform'ing) form to
pass its own name as the parameter on the OpenForm call. Then the
called (ie. calendar) form could use the following statement to return
a value in the public variable BLAH defined in the calling form:

forms(me.openargs).BLAH = ...

(2) The calendar form could return its value in a pre-defined public
variable that is defined in any standard (non-form) module. Then the
calling form can read it from there.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
G

Guest

TC,
thanks for the reply. I thought about using a Public Variable on the way in
today and set Public CallingForm as string in a module

On the OnClick() event button that opens the DateSetter form I have the
CallingForm variable set to the name of the form the user is on. I have
proven the variable is being assigned.

The DateSetter form opens and the calendar control works. What I haven't
figured out is how to use the CallingForm variable to set the control values
on the form that made the original call.

For example, this code works for the named form only:

[Forms]![REPORTING - FACILITIES].[DateIN] = Me.startdate
[Forms]![REPORTING - FACILITIES].[DateOUT] = Me.enddate

what I need is:

Forms(CallingForm).[DateIN] = Me.startdate
Forms(CallingForm).[DateOUT] = Me.enddate

I haven't found the proper syntax yet. Can you help?
 
T

TC

If you were going to do this by using a Public variable defined in a
module not attached to a form - there would be no point having the
calling form, pass its own name in that variable. Instead, have the
/called/ (calendar) form, put the selected date, into that variable,
before it returns. Then the /calling/ form can retrieve that value,
from that variable.

Something like:

Module (not attached to a form):
Public gDate as date

calling form:
docmd.open form "calendar", ... acDialig
msgbox "The selected date was " & gDate

called (calendar) fom:
...
gDate = ...
docmd.close acForm, me.name

Does that help?

TC (MVP Access)
http://tc2.atspace.com
 

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