From: TL on
See code below:

Private Sub Form_AfterUpdate()
Me.Parent!LOTOGroup
End Sub

I'm not sure what the cntrl-G reference is.

"Armen Stein" wrote:

> On Tue, 23 Mar 2010 07:08:08 -0700, TL <TL(a)discussions.microsoft.com>
> wrote:
>
> >I have tried the code you detailed but keep coming up with a "Compile
> >Error:Syntax Error"
> >
> >Not sure whether the "Parent" section of the "Me.Parent!LOTOGroups" code
> >referenced the mainform I tried leaving it as parent and also entering the
> >mainforms name and keep receiving above error.
> >
> >The subform combo box "LOTOGroups" enters data into a LOTOtable.
> >The LOTOtable has a one-to-many relationship with a PREVENTTable.
> >The mainforms combo box "LOTOGroup" has a row source of "SELECT [LOTO
> >Table].[LOTOGroups] FROM [LOTO Table] ORDER BY [LOTOGroups];"
> >
> >I'm note sure where I'm going wrong - could it be the query behind the
> >mainform?
>
> The rowsource of the combobox shouldn't be an issue, nor should the
> query behind they main form. You're having trouble just referencing
> the combobox, which result in a compile error. The fact that it is a
> syntax error means that you likely haven't written the line of code
> correctly. Post your exact code for us to look at.
>
> Also, use the immediate window (Ctrl-G) while your form is open to try
> a direct reference.
>
> ?Forms!MyMainFormName!LOTOGroups
>
> Does that return a value? If not, maybe the form isn't truly the top
> level form, maybe it is another subform?
>
> Armen Stein
> Microsoft Access MVP
> www.JStreetTech.com
>
> .
>
From: John W. Vinson on
On Tue, 23 Mar 2010 12:14:01 -0700, TL <TL(a)discussions.microsoft.com> wrote:

>See code below:
>
>Private Sub Form_AfterUpdate()
>Me.Parent!LOTOGroup
>End Sub

This doesn't *DO* anything. It's like sending a postcard saying "Aunt Mary"
and nothing else!

--

John W. Vinson [MVP]
From: Armen Stein on
On Tue, 23 Mar 2010 14:45:27 -0600, John W. Vinson
<jvinson(a)STOP_SPAM.WysardOfInfo.com> wrote:

>>Private Sub Form_AfterUpdate()
>>Me.Parent!LOTOGroup
>>End Sub
>
>This doesn't *DO* anything. It's like sending a postcard saying "Aunt Mary"
>and nothing else!

Right. That's why you have a syntax error. As John says, you need to
DO something with that control (although I'm not sure what his Aunt
Mary has to do with it. :)

What do you want to do with it? In your original post you said you
wanted to "update" it.

Maybe:
Me.Parent!LOTOGroup = Me.MyControlOnThisSubform

We can't tell for sure, because you haven't told us.

Regarding Ctrl-G: Try pressing it when your form is open. It's the
Immediate Window, which allows you to display the values of various
controls and functions "immediately", instead of in code. If you're
going to be programming using VBA, you'll want to learn about this.
Check Access Help.

Armen Stein
Microsoft Access MVP
www.JStreetTech.com

From: TL on
What I am trying to do is update (requery?) a main form combo box after
entering data into a subform combo box?

What I previously sent was the code that was placed into the subform's
update section.

Will the "Me.Parent!LOTOGroup = Me.MyControlOnThisSubform" do this?

Is the "Parent" section of this code supposed to the name of the mainform,
or remain as parent?

I hope this helps

"Armen Stein" wrote:

> On Tue, 23 Mar 2010 14:45:27 -0600, John W. Vinson
> <jvinson(a)STOP_SPAM.WysardOfInfo.com> wrote:
>
> >>Private Sub Form_AfterUpdate()
> >>Me.Parent!LOTOGroup
> >>End Sub
> >
> >This doesn't *DO* anything. It's like sending a postcard saying "Aunt Mary"
> >and nothing else!
>
> Right. That's why you have a syntax error. As John says, you need to
> DO something with that control (although I'm not sure what his Aunt
> Mary has to do with it. :)
>
> What do you want to do with it? In your original post you said you
> wanted to "update" it.
>
> Maybe:
> Me.Parent!LOTOGroup = Me.MyControlOnThisSubform
>
> We can't tell for sure, because you haven't told us.
>
> Regarding Ctrl-G: Try pressing it when your form is open. It's the
> Immediate Window, which allows you to display the values of various
> controls and functions "immediately", instead of in code. If you're
> going to be programming using VBA, you'll want to learn about this.
> Check Access Help.
>
> Armen Stein
> Microsoft Access MVP
> www.JStreetTech.com
>
> .
>
From: Armen Stein on
On Wed, 24 Mar 2010 12:28:01 -0700, TL <TL(a)discussions.microsoft.com>
wrote:

>What I am trying to do is update (requery?) a main form combo box after
>entering data into a subform combo box?

Okay. Try:

Me.Parent!LOTOGroup.Requery

This will requery the entries in the dropdown list for that combobox.
It will NOT change the current value of the item selected in the
combobox, if any.

>What I previously sent was the code that was placed into the subform's
>update section.

That seems to be the right place, but again, we can't see everything
you have.

>Will the "Me.Parent!LOTOGroup = Me.MyControlOnThisSubform" do this?

No. It would change the VALUE of the combobox on the main form, which
is what I thought you were trying to do.

>Is the "Parent" section of this code supposed to the name of the mainform,
>or remain as parent?

My (and many others') convention is to prefix anything that needs to
be changed to *your* naming with "My". However, in this case Parent
is a property of an Access form that refers to the form that contains
it. It can even go further - Me.Parent.Parent refers to a subform's
Parent's Parent form. (Grandparent :)

Armen Stein
Microsoft Access MVP
www.JStreetTech.com