dynamic Subforms

chobo321321

Registered User.
Local time
Today, 08:27
Joined
Dec 19, 2004
Messages
53
Hi, I'm having a hard time setting the recordsource in a subform dynamically. here's what I have

Main Form code:

Code:
Public Sub Form_Current()
    Me.s_frmPurchaseOrder.Form.RecordSource = "EXEC spProductList " & Me!lstOrder
    Debug.Print s_frmPurchaseOrder.Form.RecordSource
End Sub
The debug statement displays "EXEC spProductList 4", etc.., so I'm not sure why I don't see it in the recordsource.

When I run the main form and click the listbox record (lstOrder) to give the stored procedure a new value, nothing displays in the subform. I then go to design view and check the subforms recordsource, and it is blank. Does anyone have any ideas on why the recordsource is not being set? Any help is appreciated.
 
I found out the recordsource is being set, and if I put in a specific value for the (lstorder) it will display that record in the subform fields. But, I am having problems getting the record in the subform to switch when I select a different record in the listbox.

In my textbook it says to put the code to set the recordsource in the form_current() event, but that event only seems to run on form loadup, and doesn't do anything if I click on a new records in the lstOrder listbox
 
DEfine an After Update event against your listbox and use eithet the method Requery or the method Refresh, depending on whether your subform is based on a query or not.

Review Access Help for info regarding these Methods.

RV
 
Thanks for the help, the afterupdate and requery method worked perfectly :)
 

Users who are viewing this thread

Back
Top Bottom