Subform loses connection to subform

BJF

Registered User.
Local time
Yesterday, 23:38
Joined
Feb 19, 2010
Messages
137
Hi everyone!

I am a new poster to the site and hope to learn much here!

I have a Sales order form that has a product subform within it.
The product is selected by a combobox which pulls a few numbers in addition to selecting the product code number itself.

In case the info retrieved from the combobox does not appear to be up to date, i put code on the dbl click event of the combobox to open the product form so that changes can be made.

When i return back to the sales order form, it requeries fine and all is good, until I go to create a new sales order. When i do this, the subform remains on that last record until i close the form and reopen it.

is it wrong to navigate away from the form in that manner?????!!
I dont get why it would lose connection...

any suggestions

Thank you - Brian
 
Welcome Brian

Is the product form a subform or not?

You talk about opening it. If it's a subform then it's already open (as part of the sales form). It's just a matter of how you are making the current record in the product subform equal the product selected in the combobox. Do that by setting the Master and Child fields properties of the subform control (the control that contains the subform) and then it will always display the selected product in the subform without any coding required.
 
Hi thanks very much for the welcome and for replying!

No, the product form is not a subform. My Sales order form (frmSalesOrders) contains a subform (fsubProduct), which has a combobox that gets it rowsource from another form / table (frmStandardCost). So if i'm writing a sales order and want to make an adjustment to a product cost without closing the sales order, I double click in the combobox which opens up frmStandardCost to the currently selected product so that i may edit it and then return back to the sales order with the correct cost. This proceedure works out fine.... but then when i click the asterisk on my sales order form to create a new sales order, the subform should be new as well ....but its not, it gets stuck on whatever record is was on from the last sales order.

The weird thing is, the subform works 100% fine if i dont dbl click the combobox (in a case where i dont need to edit anything in my standard cost form for the product).

The link between parent and subform is broken as soon as I dbl click the combobox to open my standard cost form, not after closing the standard cost form(which has code to requery the combobox of my sales order attached to the close button)

The break happens after running this code:

Private Sub ProductNum_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmStandardCost", acNormal, , "[ProductNum]='" & Me![ProductNum] & "'"

End Sub

All it does is open my other form to that record - I dont seee how the break is happening????

Sorry such a long explanation! Hope it was clear
Please respond!
Thanks very much,
Brian
 
Hmm, odd.

I know you say the subform works when you don't double click but I think it would be worth checking it is setup correctly.

It is linked to the parent form with Master/Child fields yes? It's not being done through filters?

Perhaps you could create a new database, import the required tables, queries and forms for these forms and upload it with dummy (or no) data. I'd suggest importing everything into a new database anyway just to check it's not corrupted.

There's always the possibility of putting code in that should 'rejoin' the subform (set its source object to nothing and then back again to the subform would probably do it) but it would be better to eliminate the cause rather than fix the symptom.
 

Users who are viewing this thread

Back
Top Bottom