requery a combo box on a subform

G

Gen

hello,

I have a form, Purchase Orders, containing the subform Purchase oRder
Subform. I want to limit the products on the subform based on the supplier
selected on the main form. I already wrote the select code into the row
source of the products, and it works (kinda), but I can't requery after
updating the suppliers. I wrote a requery macro and put it in the "After
Update" event using the control name:

Forms![Purchase Order]![Purchase Order Subform].Form![ProductID]

and a variety of these combinations, but they all give the same results: an
error saying there is no such feild in the current record. The sbuform is
linked ot the main form by a PO number. I don't know very much VB.

Please help!
 
S

Scott

use VBA find the afterupdate of the supplier field
Private Sub supplierfield_AfterUpdate()
Me.PurchaseOrderSubform.requery

hope this helps
 
G

Gen

Thank you both for the quick response, unfortunatly neither suggestion
worked. When I use the VBA code, I get a message saying there is syntax error
and its highlighted the phrase

Private Sub SupplierID_AfterUpdate()

Which doesn't make a lot of sense to me since access wrote it! When I use
the different control name suggested I still get the error "There is no Field
named '[Forms]![Purchase Order]![Purchase Order Subform]![ProductID]' in the
current record.

Any other suggestions?


KARL DEWEY said:
Try this ----
[Forms]![Purchase Order]![Purchase Order Subform]![ProductID]

--
KARL DEWEY
Build a little - Test a little


Gen said:
hello,

I have a form, Purchase Orders, containing the subform Purchase oRder
Subform. I want to limit the products on the subform based on the supplier
selected on the main form. I already wrote the select code into the row
source of the products, and it works (kinda), but I can't requery after
updating the suppliers. I wrote a requery macro and put it in the "After
Update" event using the control name:

Forms![Purchase Order]![Purchase Order Subform].Form![ProductID]

and a variety of these combinations, but they all give the same results: an
error saying there is no such feild in the current record. The sbuform is
linked ot the main form by a PO number. I don't know very much VB.

Please help!
 
G

Gen

OK I've got this finally working,

I had to use VBA to set up the requery not just on the after update property
but also on current. I used :

Me.[SubformName].Form.FieldName.Requery

And I also used the WHERE clause in the ProductID field to limit to the
SupplierID in the main form. Great!

PROBLEM: The subform will only list items that have previously been
ordered. Therefore, if I add new items to the Items Table (separate from
purchase orders table) I cannot see them on the form. BUT I can add them
using the table (obviously not ideal).

Gen said:
Thank you both for the quick response, unfortunatly neither suggestion
worked. When I use the VBA code, I get a message saying there is syntax error
and its highlighted the phrase

Private Sub SupplierID_AfterUpdate()

Which doesn't make a lot of sense to me since access wrote it! When I use
the different control name suggested I still get the error "There is no Field
named '[Forms]![Purchase Order]![Purchase Order Subform]![ProductID]' in the
current record.

Any other suggestions?


KARL DEWEY said:
Try this ----
[Forms]![Purchase Order]![Purchase Order Subform]![ProductID]

--
KARL DEWEY
Build a little - Test a little


Gen said:
hello,

I have a form, Purchase Orders, containing the subform Purchase oRder
Subform. I want to limit the products on the subform based on the supplier
selected on the main form. I already wrote the select code into the row
source of the products, and it works (kinda), but I can't requery after
updating the suppliers. I wrote a requery macro and put it in the "After
Update" event using the control name:

Forms![Purchase Order]![Purchase Order Subform].Form![ProductID]

and a variety of these combinations, but they all give the same results: an
error saying there is no such feild in the current record. The sbuform is
linked ot the main form by a PO number. I don't know very much VB.

Please 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