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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scroll bars fix using setFocus?

Status
Not open for further replies.

dbaJSmith

Programmer
Sep 17, 2008
42
0
0
US
Hello all:
I have a form with several vertical scrolling subforms (form view), each placed on a separate tab. Throughout use of the form I am changing the visibility of the tab control, which hides all the subforms (but does not close them). However, each time that I "reveal" the tab, each subform remains at the last scrolled location. I want to reset the scrollbars to the top of the form after the tab is "hidden".

To do this, I had planned on setting the focus to a textbox control at the top of each subform. the problem is, I can't seem to get the call working correctly. This is what I wrote:

Code:
Forms!frm_DataEntry.sbf_tab_Billing.txt_Scroll.SetFocus

which generates an "Object doesn't support property or method" error. I want to call this code from a button object on the main form.

Am I referencing the object incorrectly? I'm not used to calling objects this way: I usually use the me. method. Thanks!
 
I just experienced this last week where I need to display all the records in subform after I updated a list box that was used to Link Master/Child. This is the code I used.
Code:
Private Sub lboIPN_AfterUpdate()
    Dim rs As DAO.Recordset
    On Error GoTo lboIPN_AfterUpdate_Error

    Set rs = Me.sfrmLinComMach.Form.RecordsetClone
    rs.FindFirst "1=1"
    Me.sfrmLinComMach.Form.Bookmark = rs.Bookmark
    Set rs = Nothing

    On Error GoTo 0
    Exit Sub

lboIPN_AfterUpdate_Error:
    Select Case Err.Number
        Case 3021  'no records
        Case Else
            MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure lboIPN_AfterUpdate of VBA Document Form_frmIPNEdit"
    End Select
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Before you hide the subform:
Code:
With Me!sbf_tab_Billing
  .SetFocus
  .Form!txt_Scroll.SetFocus
  Me.Setfocus
  .Visible = False
End With

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV: Perfect! Just the .form!txt_Scroll.SetFocus does everything I need it to. I see now how the path runs. Thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top