The code works the way you are doing, but if you want something more generic create a Class Module or do it as follows:
As I do not know how the whole structure of your form is and what you really want from page 2, this is an example to learn loops in form controls and generalize some tasks that can work on every page.
Code
Option Explicit
Private Sub MultiPage1_Change()
Dim controle As Control
Dim pagina_atual As Long
Dim tudo_vazio As Boolean
tudo_vazio = True
With Me.MultiPage1
pagina_atual = .Value
For Each controle In .Pages(pagina_atual).Controls
If TypeName(controle) = "TextBox" Then
If Trim(controle.Value) <> "" Then
'Debug.Print controle.Name
tudo_vazio = False
Exit For
End If
End If
Next controle
If tudo_vazio Then
For Each controle In .Pages(pagina_atual).Controls
If TypeName(controle) = "CommandButton" Then
'Debug.Print controle.Name
If Not Trim(controle.Name) Like "*habilitar*" Then
controle.Enabled = False
End If
End If
Next controle
End If
End With
End Sub
Explanation
When looping in the form controls of the current page and checking to see if there are no empty Text Boxes.
Current Page
The code pagina_atual = Me.MultiPage1.Value
returns the value of the selected multipage page.
Loop in controls
For Each controle In Me.MultiPage1.Pages(pagina_atual).Controls
Next controle
Loops all controls on the selected multipage page.
Check if text box
If TypeName(controle) = "TextBox" Then
End If
Checks whether the control is a text box.
Check if something was written in the Text Box
If Trim(controle.Value) <> "" Then
End If
Checks if the value of the text box is different from empty.
If it is not empty
tudo_vazio = False
Exit For
If the control is not empty, that is, with some value. Changes the flag tudo_vazio
to False and exits the loop.
Check the flag tudo_vazio
If tudo_vazio Then
End If
If tudo_vazio
is true, continue with the code.
Loop controls and check button
As before, the loop in the controls is checked and checked to see if it is a Command Button.
Check Command Button Name
As the Text_Box are all empty, it means that there was no change. Then all buttons that do not contain the word enable in the name will be disabled with controle.Enabled = False
If Not Trim(controle.Name) Like "*habilitar*" Then
End If