GoToRecord for tabbed form within Navigation Form

N8 0 Reputation points
2024-10-24T18:52:51.7166667+00:00

From the frmMainForm, I have 3 buttons; button one opens a tblTable1, button two opens frmForm2, and button three opens frmNavForm. My GoToRecord VBA works perfectly when just frmForm2 is opened, but it will not work when its under a tab in frmNavForm. Since frmForm2 can be opened and worked by itself, I need the code to continue to work when just frmForm2 is open, but I also need it to do the same thing when its loaded via a tab click in the frmNavForm. I have tried select object, set focus, and a couple of other means, but nothing has worked yet. I would appreciate some assistance on what I am doing wrong. I have researched many of blogs and FQA's, but nothing I have found and tried has worked (maybe I am putting the VBA under the wrong form(s). Below is the detailed info about the forms.

frmMainForm

  • Button one opens tblTable1
  • Button two opens frmForm2 (form has tabs)
  • Button three opens frmNavForm which is a navigation form that has frmForm2 under one of the tabs

frmForm2

  • The Form has a Record Source as tblTable1
  • The VBA below works when just opening frmForm2, but does not work when it opens via frmNavForm
Private Sub Form_Load()
Me.TabCtl0.Value = 0
TabCtl0_Change
End Sub

Private Sub TabCtl0_Change()
    Select Case Me.TabCtl0.Value
        Case 0
            DoCmd.GoToRecord acDataForm, "frmForm2", acGoTo, 2
        Case 1
            DoCmd.GoToRecord acDataForm, "frmForm2", acGoTo, 3
        Case 2
            DoCmd.GoToRecord acDataForm, "frmForm2", acGoTo, 4
        Case 3
            DoCmd.GoToRecord acDataForm, "frmForm2", acGoTo, 5
        Case 4
            DoCmd.GoToRecord acDataForm, "frmForm2", acGoTo, 6
        Case 5
            DoCmd.GoToRecord acDataForm, "frmForm2", acGoTo, 7
        Case 6
            DoCmd.GoToRecord acDataForm, "frmForm2", acGoTo, 8
        Case 7
            DoCmd.GoToRecord acDataForm, "frmForm2", acGoTo, 9
        Case 8
            DoCmd.GoToRecord acDataForm, "frmForm2", acGoTo, 10
        Case 9
            DoCmd.GoToRecord acDataForm, "frmForm2", acGoTo, 11
        Case 10
            DoCmd.GoToRecord acDataForm, "frmForm2", acGoTo, 12
        Case 11
            DoCmd.GoToRecord acDataForm, "frmForm2", acGoTo, 13
    End Select
End Sub



Access
Access
A family of Microsoft relational database management systems designed for ease of use.
402 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.