Refreshing data in a subform

P

Phil Hood

I have a main form (linked to a table) with an event
procedure that populates a 2nd table for which a subform
exists. The event procedure is set to occur 'After Update'
of the main form.


I want to be able to refresh the subform automatically so
it shows the data added by the event procedure of the main
form.


How do I do this?

Thanks for your help.
 
A

Al Borges

How about:

Forms![MainForm1]![Subform].form.refresh

Alternatively, you could do:

Forms![Form1].RecordSource = "SELECT YourTable1.* FROM YourTable1 ORDER BY
YourTable1.ddate; "

Regards,
Al
 
P

Phil Hood

Hi,

Thanks for your suggestion but I still can't make it work.

The code for the event procedure 'after update' on
form 'Heat' is:

-----------------------------------------------
Private Sub Form_AfterUpdate()

Dim stDocName As String

stDocName = "Query2"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Forms![Heat]![Results Subform].form.refresh

End Sub
------------------------------------------------

Query 2 adds a record to a table called 'Results' which is
displayed through a form called 'Results' which is a
subform of 'Heat'.

However, the subform is not refreshed by the code in
the 'After update' procedure but if I refresh the page
manually (through the drop down menus it does populate the
subform with the results of query2

Any thoughts?

Also, I'm afraid I don't understand your 2nd suggestion:

Forms![Form1].RecordSource = "SELECT YourTable1.* FROM
YourTable1 ORDER BY
YourTable1.ddate; "

Can you explain.

Thanks

Phil.
-----Original Message-----
How about:

Forms![MainForm1]![Subform].form.refresh

Alternatively, you could do:

Forms![Form1].RecordSource = "SELECT YourTable1.* FROM YourTable1 ORDER BY
YourTable1.ddate; "

Regards,
Al

Phil Hood said:
I have a main form (linked to a table) with an event
procedure that populates a 2nd table for which a subform
exists. The event procedure is set to occur 'After Update'
of the main form.


I want to be able to refresh the subform automatically so
it shows the data added by the event procedure of the main
form.


How do I do this?

Thanks for your help.


.
 
A

Al Borges

Also, I'm afraid I don't understand your 2nd suggestion:
Forms![Form1].RecordSource = "SELECT YourTable1.* FROM
YourTable1 ORDER BY YourTable1.ddate; "

Hi Phil:

Look at the subform's "Record Source" property, highlight it, copy it, then
use it in the above line to force a change/forced refresh of your subform.
It should work very well. Guaranteed.

Regards,
Al

Phil Hood said:
Hi,

Thanks for your suggestion but I still can't make it work.

The code for the event procedure 'after update' on
form 'Heat' is:

-----------------------------------------------
Private Sub Form_AfterUpdate()

Dim stDocName As String

stDocName = "Query2"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Forms![Heat]![Results Subform].form.refresh

End Sub
------------------------------------------------

Query 2 adds a record to a table called 'Results' which is
displayed through a form called 'Results' which is a
subform of 'Heat'.

However, the subform is not refreshed by the code in
the 'After update' procedure but if I refresh the page
manually (through the drop down menus it does populate the
subform with the results of query2

Any thoughts?

Also, I'm afraid I don't understand your 2nd suggestion:

Forms![Form1].RecordSource = "SELECT YourTable1.* FROM
YourTable1 ORDER BY
YourTable1.ddate; "

Can you explain.

Thanks

Phil.
-----Original Message-----
How about:

Forms![MainForm1]![Subform].form.refresh

Alternatively, you could do:

Forms![Form1].RecordSource = "SELECT YourTable1.* FROM YourTable1 ORDER BY
YourTable1.ddate; "

Regards,
Al

Phil Hood said:
I have a main form (linked to a table) with an event
procedure that populates a 2nd table for which a subform
exists. The event procedure is set to occur 'After Update'
of the main form.


I want to be able to refresh the subform automatically so
it shows the data added by the event procedure of the main
form.


How do I do this?

Thanks for your help.


.
 
P

Phil Hood

Al,

Would you expect the expression to look like this:

Forms![Results Subform].SELECT DISTINCTROW [Results].
[ResultID], [Results].[HeatID], [Results].[MatchID],
[Results].[RiderID], [Results].[RideType], [Results].
[RideNo], [Results].[Result] FROM [Results]; = "SELECT
Results.* FROM Results ORDER BY Results.ddate; "

Because it still doesn't achieve the refresh of the
subform.

Phil.

-----Original Message----- suggestion:
Forms![Form1].RecordSource = "SELECT YourTable1.* FROM
YourTable1 ORDER BY YourTable1.ddate; "

Hi Phil:

Look at the subform's "Record Source" property, highlight it, copy it, then
use it in the above line to force a change/forced refresh of your subform.
It should work very well. Guaranteed.

Regards,
Al

Phil Hood said:
Hi,

Thanks for your suggestion but I still can't make it work.

The code for the event procedure 'after update' on
form 'Heat' is:

-----------------------------------------------
Private Sub Form_AfterUpdate()

Dim stDocName As String

stDocName = "Query2"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Forms![Heat]![Results Subform].form.refresh

End Sub
------------------------------------------------

Query 2 adds a record to a table called 'Results' which is
displayed through a form called 'Results' which is a
subform of 'Heat'.

However, the subform is not refreshed by the code in
the 'After update' procedure but if I refresh the page
manually (through the drop down menus it does populate the
subform with the results of query2

Any thoughts?

Also, I'm afraid I don't understand your 2nd suggestion:

Forms![Form1].RecordSource = "SELECT YourTable1.* FROM
YourTable1 ORDER BY
YourTable1.ddate; "

Can you explain.

Thanks

Phil.
-----Original Message-----
How about:

Forms![MainForm1]![Subform].form.refresh

Alternatively, you could do:

Forms![Form1].RecordSource = "SELECT YourTable1.* FROM YourTable1 ORDER BY
YourTable1.ddate; "

Regards,
Al

I have a main form (linked to a table) with an event
procedure that populates a 2nd table for which a subform
exists. The event procedure is set to occur 'After Update'
of the main form.


I want to be able to refresh the subform
automatically
so
it shows the data added by the event procedure of the main
form.


How do I do this?

Thanks for your help.


.


.
 
A

Al Borges

Hi Phil:

Let's call your "parent" form [ParentForm] and your "child" form
[ChildForm]. Go to design view of the form, click on the [ChildForm], then
click on the "Properties" icon. The very first property is the "Record
Source" and you'll see something like "SELECT Table1.* FROM Table1 ORDER BY
[Table1].[ddate];" (without the quotes). This is what you need to tweek to
get the form refreshed.

Your "record source" statement thus would be most likely something like the
"SELECT Results.* FROM Results ORDER BY Results.ddate; " that you just
posted. You need to send this via code to the subform's "record source"
property. Here's the way-

Forms![ParentOfResultsSubform]![Results Subform].form.recordsource = "SELECT
Results.* FROM Results ORDER BY Results.ddate; "

Let me know if you get it to work...

BTW, I don't know where you got the part:
Forms![Results Subform].SELECT DISTINCTROW [Results]...

Al

Phil Hood said:
Al,

Would you expect the expression to look like this:

Forms![Results Subform].SELECT DISTINCTROW [Results].
[ResultID], [Results].[HeatID], [Results].[MatchID],
[Results].[RiderID], [Results].[RideType], [Results].
[RideNo], [Results].[Result] FROM [Results]; = "SELECT
Results.* FROM Results ORDER BY Results.ddate; "

Because it still doesn't achieve the refresh of the
subform.

Phil.

-----Original Message-----
Also, I'm afraid I don't understand your 2nd
suggestion:
Forms![Form1].RecordSource = "SELECT YourTable1.* FROM
YourTable1 ORDER BY YourTable1.ddate; "

Hi Phil:

Look at the subform's "Record Source" property, highlight it, copy it, then
use it in the above line to force a change/forced refresh of your subform.
It should work very well. Guaranteed.

Regards,
Al

Phil Hood said:
Hi,

Thanks for your suggestion but I still can't make it work.

The code for the event procedure 'after update' on
form 'Heat' is:

-----------------------------------------------
Private Sub Form_AfterUpdate()

Dim stDocName As String

stDocName = "Query2"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Forms![Heat]![Results Subform].form.refresh

End Sub
------------------------------------------------

Query 2 adds a record to a table called 'Results' which is
displayed through a form called 'Results' which is a
subform of 'Heat'.

However, the subform is not refreshed by the code in
the 'After update' procedure but if I refresh the page
manually (through the drop down menus it does populate the
subform with the results of query2

Any thoughts?

Also, I'm afraid I don't understand your 2nd suggestion:

Forms![Form1].RecordSource = "SELECT YourTable1.* FROM
YourTable1 ORDER BY
YourTable1.ddate; "

Can you explain.

Thanks

Phil.

-----Original Message-----
How about:

Forms![MainForm1]![Subform].form.refresh

Alternatively, you could do:

Forms![Form1].RecordSource = "SELECT YourTable1.* FROM
YourTable1 ORDER BY
YourTable1.ddate; "

Regards,
Al

I have a main form (linked to a table) with an event
procedure that populates a 2nd table for which a subform
exists. The event procedure is set to occur 'After
Update'
of the main form.


I want to be able to refresh the subform automatically
so
it shows the data added by the event procedure of the
main
form.


How do I do this?

Thanks for your help.


.


.
 

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