1

I need to update the Page Caption on a Tab Control in Access. I tried the following code:

Private Sub tabName_AfterUpdate()
  MyTabControl.Pages(Me.MyTabControl.Value).Caption = Me.tabName
End Sub

This works well to set the Caption, but after using Tab or Enter in the field and execution of the above code I end up on the next record. What can I do to stay on the same page?

Private Sub tabName_AfterUpdate()
  MyTabControl.Pages(Me.MyTabControl.Value).Caption = Me.tabName
  Forms!frmMailing.Controls!MyTabControl = Me.MyTabControl.Value
End Sub

leads to the next record as well, while

Private Sub tabName_AfterUpdate()
  MyTabControl.Pages(Me.MyTabControl.Value).Caption = Me.tabName
  Forms!frmMailing.Controls!MyTabControl = Me.MyTabControl.Value-1
End Sub

Will jump to the previous page of the same record (as expected)!

braX
  • 11,506
  • 5
  • 20
  • 33
Blacksmith
  • 27
  • 7
  • After some more testing I found this workaround (without being the proper solution): Private Sub tabName_AfterUpdate() MyTabControl.Pages(Me.MyTabControl.Value).Caption = Me.tabName Forms!frmMailing.Controls!MyTabControl = Me.MyTabControl.Value-1 Forms!frmMailing.Controls!MyTabControl = Me.MyTabControl.Value+1 End Sub Be aware: This will not work on Page(0)! For my problem however the Tabs to be renamed have always an index greater than 1, so this will work always. – Blacksmith May 11 '20 at 14:11

1 Answers1

-1

please try following code example:

Forms("dataimport").Command8.Caption = "test"
DoEvents

command8 = control at the form "dataimport" also the form should be opened

Alexander
  • 29
  • 6