[AccessD] Second Try

John Colby jwcolby at gmail.com
Fri Mar 11 07:06:35 CST 2022


Arthur, if you open a popup form, then there is no me.parent.

Parent is only valid for a control in a form.  And a subform in a form is
actually a control itself.  A popup form OTOH is not a control in the form
that caused it to open.  It is just another open form

So Me refers to that form just popped up.  Parent refers to?????  Nothing.

In fact me refers to the instance of the current class, and what is really
true is that the form itself has a code behind form class, and me refers to
that class, in the context of the code running at the instant that you try
to refer to me.

One way or another, a popup has no parent.  It does have a "me", which is
the code behind form class, but the form that caused the popup to open is
NOT the parent of that form.

On Thu, Mar 10, 2022 at 7:51 PM Arthur Fuller <fuller.artful at gmail.com>
wrote:

> Earlier today I posted a message, or thought I did, but haven't seen it
> appear yet, so I'm resending it.
>
> I have a form in datasheet format. It's actually a subform. The bottom row
> contains the word New. When I click this, I open a single-row form that
> allows editing or addition, depending on the argument I pass. The problem
> is that when adding a new row, the form does not inherit the parent key.
> For example, if I'm trying to add an Order Detail, it does not inherit the
> Order_ID. I have tried a few approaches but am not getting what I want.
>
> This does not work.
> <code<
>     DoCmd.OpenForm "Order_Detail_frm", View:=acNormal, DataMode:=acFormAdd
>     Me.Order_ID = Me.Parent.OrderID
> '    DoCmd.OpenForm "Order_Detail_frm", acNormal, , "ID=" & Me.ID,
> acFormEdit, acDialog
> </code>
> Any suggestions?
>
> Arthur
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


-- 
John W. Colby
Colby Consulting


More information about the AccessD mailing list