subform refresh problems

C

Chad Cromer

Hi,
I am trying to refresh or requery a subform on a form.

I have Form "HouseCostForm"
With combo box "Supplier Tag" on it.

When I change this combo box, I would like to have the
data from the subform refresh.

In the subform "SupplierQuoteSubQuerySubform1"

I have another pulldown combo box called "quote"

This is the data that I really want updated.

Have tried


Private Sub Supplier_tag_AfterUpdate()


Dim ctlList As Control
Dim stFrmName1 As String
Dim stFrmName2 As String

stFrmName2 = "SupplierQuoteSubQuerySubform1"
stFrmName1 = "HouseCostForm"

Set ctlList = Forms!stFrmName1!Quote

ctlist.Requery

Set ctlList = Forms!stFrmName2!Quote

ctlist.Requery


DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, ,
acMenuVer70
End Sub

Both methods give me a run time error of 2450 in which it
can not find the
Forms.
I have checked & rechecked the spellings, but have no luck

If you have any suggestions, please reply

Peace through Jesus
Chad Cromer
 
K

Kel

Firstly, your syntax looks to be slightly wrong for referencing forms: The
code you are using is actually looking for a form named 'stFrmName1', hence
it isn't finding it! If you are using the name of a form assigned to a
string variable (as you seem to be) to reference the form then you need to
use:

Forms(stFrmName1)

Otherwise you could use:

Forms!HouseCostForm

Secondly, when referencing a subform, it has be referenced in the context of
the parentform, e.g.

Forms!HouseCostForm!SupplierQuoteSubQuerySubform1

So for your example, the following should work:

Set ctlList = Forms!HouseCostForm!SupplierQuoteSubQuerySubform1!Quote
ctlList.Requery


Hope this helps!
Kel
 

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