PLEASE HELP: Refresh a subform

S

sam

Hi All,

I am really strugling with refreshing a subform with updated results.

Basically, I have certain search criterias and a search button in the form
header, and a sub form in the form detail section. So once a user enters any
search criteria and hits search, the results should be displayed in the
subform below. BUT the subform doesnt display any results unless I reopen the
form. Is there a way to refresh this subform?

I have tried a million things to make it work, but it doesnt refresh the
subform with the new query results.

Thanks in advance
 
D

Dirk Goldgar

sam said:
Hi All,

I am really strugling with refreshing a subform with updated results.

Basically, I have certain search criterias and a search button in the form
header, and a sub form in the form detail section. So once a user enters
any
search criteria and hits search, the results should be displayed in the
subform below. BUT the subform doesnt display any results unless I reopen
the
form. Is there a way to refresh this subform?

I have tried a million things to make it work, but it doesnt refresh the
subform with the new query results.


Is the subform's recordsource a query that refers to the fields on the form
for criteria? If so, you probably have to requery the subform:

Me.sfYourSubformName.Requery
 
S

sam

Hey Dirk,

How do I assign a record source to a subform?? I have assigned the
recordsource to the main form but how do i do it to subform?

Thanks in advance
 
D

Dirk Goldgar

sam said:
Hey Dirk,

How do I assign a record source to a subform?? I have assigned the
recordsource to the main form but how do i do it to subform?


I'm not sure I understand the question. Normally, when you built your
subform as a form object, you would have given it a recordsource (or the
form wizard would have done so). Are you asking about how to change this
recordsource manually? Or about how to change it dynamically, via VB code?

Bear in mind that there can be some confusion between the subform control on
the parent form, which displays a child form in a window, and the form
object itself that the control displays. The subform *control* doesn't have
a recordsource; that's a property of the "source object" form that the
subform control displays.

What is your actual setup? What are the names of the ...

1. Main form?

2. Subform control (on the main form)?

3. Subform source-object form?

What is in the RecordSource property of the source-object form?
 
S

sam

Hi Dirk,

What is your actual setup?

I have search criterias in form header where users select search criterias
and click search, Now those search results are displayed as a query
result(newQuery). What I want is to display those query result in the
subform(which I am able to do) But for some reason the subform doesnt
refresh. SO once I close this form and reopen it then I see the subform with
the updated results.


What are the names of the ...

1. Main form?
Form1

2. Subform control (on the main form)?
What do you mean by Subform control? If you mean name of the subform then
its ChildForm1


3. Subform source-object form?

SourceObject of the subform is "Query.newQuery"

What is in the RecordSource property of the source-object form?
What do you mean by RecordSource property of the source-object form?
The name of the RecordSource is "newQuery"

Thanks in advance
 
D

Dirk Goldgar

sam said:
Hi Dirk,


I have search criterias in form header where users select search criterias
and click search, Now those search results are displayed as a query
result(newQuery). What I want is to display those query result in the
subform(which I am able to do) But for some reason the subform doesnt
refresh. SO once I close this form and reopen it then I see the subform
with
the updated results.


What do you mean by Subform control? If you mean name of the subform then
its ChildForm1



SourceObject of the subform is "Query.newQuery"

What do you mean by RecordSource property of the source-object form?
The name of the RecordSource is "newQuery"


Ah, I see. You haven't created a separate form to be displayed in
ChildForm2; you're just displaying a query. Please open the query
"newQuery" in SQL view, and copy/paste the SQL into a reply to this message.

If the query is already using your form's filtering controls as criteria,
all you should have to do is have your Search button requery the subform,
using a line like this in the button's Click event procedure:

Me.ChildForm1.Requery

But if your query isn't already using the form controls as criteria, it will
have to be modified so that it does.
 

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