Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / March 2006

Tip: Looking for answers? Try searching our database.

Set focus to particular record using Continuous Forms

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kaeldowdy@hotmail.com - 30 Mar 2006 17:46 GMT
This one is stumping me!

I have a Form/Subform arrangement. The main form is set as a Single
Form and the sub form is set as Continuous Forms.

On the Form_AfterUpdate event of the subform, I run some code that
affects the main form which forces focus *away* from the subform and
puts it to the main form.

I need to keep focus on the subform when the code in the
Form_AfterUpdate event finishes.  Sounds simple enough, right!?  I
tried a Me.CtrlName.SetFocus in the subform after I'm done running my
code.  However, in continuous forms, it defaults back to the *first*
row.  I'm wanting to set focus back to a specific row/instance in the
subform.

I tried DoCmd.RunCommand acCmdRecordsGoToLast and the like, but I want
to get focus to where I last left off, not the first, last, new, etc.
record.

I do have a hidden unique identifier if that would be used as part of
the solution.

Any thoughts?  If you need more info, let me know!

Thanks,
Kael
kaeldowdy@hotmail.com - 30 Mar 2006 18:34 GMT
Well, I think I got it figured out.  It was easier than I thought...

Form_AfterUpdate()
  Dim lngPosition as Long

  lngPosition = Me.CurrentRecord ' capture index position of record
currently selected

  ' *** do my code where my subform loses focus to parent form ***

  Me.ControlName.SetFocus ' go back to sub form

  Me.Form.Recordset.Move lngPosition ' navigate back to original
record position
End Sub

I still have some debugging to be sure its fine tuned correctly to
account for all possible situations, but this got me 90% of the way
there.  I guess it was easier than I thought (Me.CurrentRecord and
Me.SelTop didn't jump out at me at first!)

Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.