Connecting Tech Pros Worldwide Forums | Help | Site Map

requery a subform on a form

ken
Guest
 
Posts: n/a
#1: Nov 13 '05
Hi,
I have a main form with a text box and a filter button. I also have a
subform in the main form. When I make an entry into the filter text box
and click the filter button, I change the query definition of the
subform and then try to requery the subform, but no matter what I do it
does not requery?

While my main form is open and after I clicked on filter, I can open
the subform query and see that the sql changed correctly. I can open
the subform itself and its filtered correctly, but the subform on my
main form won't change unless I close and reopen the main form?

Does this mean that is I changed the SQL behind a query in a form I
can't see it untill I reopen the form?


ken
Guest
 
Posts: n/a
#2: Nov 13 '05

re: requery a subform on a form


Found an answer to question(This worked for me):

Steven Hemingray Jun 14 2001, 7:31 am show options
Newsgroups: microsoft.public.access
From: hall...@hotmail.com (Steven Hemingray) - Find messages by this
author
Date: 14 Jun 2001 05:31:51 -0700
Local: Thurs, Jun 14 2001 7:31 am
Subject: Re: Refreshing a subform
Reply to Author | Forward | Print | Individual Message | Show original
| Report Abuse
[color=blue]
> And where should I put that? Under the current buttons code?[/color]
[color=blue]
> "Bruce M. Thompson" <NO~SPAM_bthmp...@bigfoot.com> wrote in message
> news:0VRV6.39$9d.18943@newshog.newsread.com...[color=green]
> > Mike:[/color][/color]
[color=blue][color=green]
> > A simple "Me.NameOfSubformControl.Requery" should take care of that. This[/color]
> will,[color=green]
> > in effect, reopen the subform instance.[/color][/color]

Try putting it in the afterupdate field of the main form, or if there
is a command button used to change the data, put it at the bottom of
that.
I had a problem with this as well where just doing a requery didn't
work for me. If that's the case for you as well, put this in the
afterupdate field or the command button code:
me.subformname.form.recordsource = queryname

Also, subformname here is the name of the subform control, which isn't
always the same as the name of the form itself.

-Steven

Wayne Gillespie
Guest
 
Posts: n/a
#3: Nov 13 '05

re: requery a subform on a form


On 7 Sep 2005 19:37:52 -0700, "ken" <gevayl@gmail.com> wrote:
[color=blue]
>Hi,
>I have a main form with a text box and a filter button. I also have a
>subform in the main form. When I make an entry into the filter text box
>and click the filter button, I change the query definition of the
>subform and then try to requery the subform, but no matter what I do it
>does not requery?
>
>While my main form is open and after I clicked on filter, I can open
>the subform query and see that the sql changed correctly. I can open
>the subform itself and its filtered correctly, but the subform on my
>main form won't change unless I close and reopen the main form?
>
>Does this mean that is I changed the SQL behind a query in a form I
>can't see it untill I reopen the form?[/color]


Requery the subform in code.
After you have changed the SQL of the subform's query, add a line like
-
Me.frmMySubForm.Form.Requery


ken
Guest
 
Posts: n/a
#4: Nov 13 '05

re: requery a subform on a form


that does not work unless I have me.subformname.form.recordsource =
queryname before Me.frmMySubForm.Form.Requery

I don't know why, but if you do..please explain. Thanks

Closed Thread


Similar Microsoft Access / VBA bytes