VBA - Hide a Form tab depending on the value of a field



  • pretty simple question here in scope.

    Question: Wondering If I would be able to hide the tabs of a form based off the values of a table's fields.

    I have been reading the 2019 Access Bible and so far it is still unclear to me how I would write the VBA module to constantly be running. Im asking the question a little early in my attempts, but hoping I can ask this well enough to get a head start.

    I dont quite understand the execution model of VBA for access yet. I have prior expierence coding but this will be my 1st time in access. Just looking for a little help on how to write the function scope. You see below that I think it should be "Main" something, as I want it to run whenever in form view. Like I know how to write Private sub functions to respond to a button click. But not for a function that just runs in the background of the form.

    I was thinking something along the line of this below.

    Main function()
    If Me.FieldProcess_Water = "1" Then
    Me.TabProcess_Water.Visible = True
    Else
    Me.TabProcess_Water.Visible  = False
    End If
    End Sub
    

    enter image description here



  • The code looks good. The point is: when to execute? In this case there are two events that should trigger the code: the Form_Current event for the form (showing a record) and the After_update event for the FieldProcess_Water control.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2