Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On returning to form move to specific row in its subform

Status
Not open for further replies.

TrekBiker

Technical User
Nov 26, 2010
330
GB
An Orders by Customer form has a datasheet subform with list of orders for the chosen customer.

Having clicked on one of the subform rows I launch an Orders form to see that order's details. The Activate procedure in the Orders form moves to the record for the selected OrderID using

Code:
DoCmd.GoToControl "OrderID"
DoCmd.FindRecord Forms![Orders by Customer]![Orders by Customer Subform].Form![OrderID]

On closing the Orders form I want to revert to the originating row in the Orders by Customer subform. At present it reverts to the top row. What will direct it properly?
 
Are you closing the orders by customer form when you launch the order details form? Try tracking the orders by customer subform and seeing what event is causing it to revert back to the top row (i.e. when you launch the order details form, when you close it, when it gets focus, etc).
 
Thanks for reply.

The Orders by Customer form remains open when two other forms are launched to show the current record in the subform.

This opens the simpler one. The originating subform record staying highlighted

Code:
        DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
        DoCmd.OpenForm "Payments", , , "[OrderID] = Forms![Orders by Customer]![Orders by Customer Subform].form![OrderID]"

The originating subform record stays highlighted as Payment data is added.

Capture_l6ykrr.jpg
.

When closing the Payments form the subform record moves to the top. This form has no Close event.

The subform has no events of any kind. Its data query did have a sort descending on Date but taking it out makes no difference.

The weird thing is the client says the copy on her system ( I think Access 2019) doesn't move away from the selected record, although my copy does (Access 2013).

I've tried using Docmd.GoToRecord to force the focus back to the originating record but haven't been able to get it right.
 
Well that's not a particularly good sign that different versions of Access are behaving differently. Usually a good indicator that the problem may be harder to sleuth than you would like.

Is there any sort of timer event or 'On Got Focus' event for the subform or the main form that houses it?

I'll be honest -- I prefer to use unbound objects so bound subforms are not my specialty. Can you store the value of the subform in an 'On Lost Focus' event and then loop through the subform until you find it in an 'On Got Focus' event (versus just using Docmd.GoToRecord)?
 
Great, thanks for your suggestions, I'll see what happens with these.

I'm a bit suspicious about the client's assessment of things like this so will go on site and see for myself! Pointing the finger at Access versions seem to be clutching at straws.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top