Requery Subform to Update Data

karl009

Registered User.
Local time
Today, 01:20
Joined
Mar 2, 2010
Messages
55
Hi,

I have a main form which has a subform that data within the subform comes from a query, I would like that data to update when I have entered in new data without having to close the form, however all my attempts seem to have fail so far here is what I have.

Three forms;
frm_Main_Form
frm_Main_Form_Sub
frm_Add_Price_Request

I have set the AfterUpdate on the form "frm_Add_Price_Request" with the code below and it returns Error 2465 missing field..

Code:
Private Sub Form_AfterUpdate()
    Forms![frm_Main_Form]![frm_Main_Form_Sub].Requery
End Sub

This same setup worked on a similar setup and I can’t see a difference.

Thanks for any help...
Karl
 
1. When referring to the subform in code you refer to the control that is on the main form that houses the subform, not the subform name itself. Normally both are named the same but if they aren't you need to use the CONTROL name and not the subform name.

2. When you want to do something on the subform itself, you need to tell Access by including a .Form. part in between.

So, if I have a subform named sfm1 in the subform control named subf1 and on main form of frmMain and I want to requery the subform I would use

Me.subf1.Form.Requery

if the code is on the frmMain form. If it isn't then I would use

Forms!frmMain.subf1.Form.Requery
 
Hi,

Thanks for the reply.

This is new to me where do you find the CONTROL name for the different forms I have, after looking on Google and Access help I didn’t find much that made sense to me or where to find the CONTROL names.

Where is the place to start looking?

Many Thanks
Karl
 
Hi,

Thanks for the reply.

This is new to me where do you find the CONTROL name for the different forms I have, after looking on Google and Access help I didn’t find much that made sense to me or where to find the CONTROL names.

Where is the place to start looking?

Many Thanks
Karl

Check the main screenshot in this tutorial out. It should show you what you need.
 
Hi,

I had a look at the site and believe I understand, however Access thinks the Control Name for the subform is a field, See the below error.



Run-time error ‘2465’
Microsoft Office Access can’t find the field ‘ListOfOpenEnq’ referred to in your expression.

Here is the code that I have used;

Code:
Private Sub Form_AfterUpdate()
    Forms("frm_Main_Form").Controls("ListOfOpenEnq").Requery
End Sub

Where am I going wrong?

Thanks
Karl
 
Hi,

Solved this, thanks for the link to the website, when I woke up I got it....

Thanks again...
Karl
 
Hi,

Solved this, thanks for the link to the website, when I woke up I got it....

Thanks again...
Karl

Cool, sometimes a good sleep is just what we need. (I think I need a lot at this point :D ) :)
 

Users who are viewing this thread

Back
Top Bottom