Reputation: 313
I've got a form in MS.Excel (VBA) with two multipages. There are multiple textboxes on both multipages. The textboxes on the second page are all starting with "txtM" plus an ascending number (txtM1, txtM2 etc.). On "Save" i'd ONLY like to remember the user if ALL of the textboxes on the second multipage (index = 1) are emtpy. Its perfectly ok if some of them are empty but a complete set of emtpy textboxes suggest, that the user simply forgot to click on the second "tab" of the multipage.
i've already tried something (see below) but have not managed to find a proper solution so far.
For Each crtl In Me.Controls
If crtl.Name Like "txtM*" Then
If crtl.Value = "" Then
MsgBox "dont forget .... blablabla"
Me.MultiPage1.Value = 1
Exit Sub
End If
End If
Next
thx & greetings, zoidie
Upvotes: 1
Views: 4042
Reputation: 35843
I would do something like this:
Dim allEmpty As Boolean
allEmpty = True
For Each crtl In Me.Controls
If crtl.Name Like "txtM*" Then
If Trim(crtl.Value) <> "" Then
allEmpty = False
Exit For
End If
End If
Next
If allEmpty Then
MsgBox "dont forget .... blablabla"
Me.MultiPage1.Value = 1
Exit Sub
End If
Upvotes: 1