frame visible problem

pwwato

New Member
Joined
Jun 10, 2017
Messages
40
Hi all I wonder if some one can help me please.

I am working on a userform on this form there are 10 frames all hidden until a number is inputted into a textbox so if textbox = 4 then 4 frames become visible, within these frames are textboxes and what the code below is doing is checking these boxes for values if they are empty it lets you know that some of the boxes are empty, this is all working fine on all frames, except I would like it to only check the visible frames and this is where I am having issues, cant seem to get the code right on this, all frames return the false msgbox even if they are visible and therefore don't check the textboxes in the frames. hope someone can help.
thanks.

Dim SB As Control
Dim SBVAL As String
Dim SFR As MSFORMS.Control
For Each SFR In REPAIR_QUOTE_FORM.MultiPage1.Pages(4).Controls
If TypeName(SFR) = "Frame" Then


If SFR.Controls.Visible = False Then
MSGVALUE = MsgBox(SFR.Name, vbOK, "false") only here to help in debugging
GoTo nextframe
ElseIf SFR.Controls.Visible = True Then
MSGVALUE = MsgBox(SFR.Name, vbOK, "TRUE")only here to help in debugging

For Each SB In SFR.Controls
If TypeName(SB) = "textbox" Then
SBVAL = SB.Value

If SBVAL = "" Then
MSGVALUE = MsgBox("SERVICE DETAIL MISSING ?" _
& vbCr & "IS THIS CORRECT?:" _
& vbCr & "NO: FOR SERVICE PAGE:" _
& vbCr & "YES: TO CONTINUE:" _
, vbYesNo + vbQuestion, "ME")
If MSGVALUE = vbNo Then
REPAIR_QUOTE_FORM.MultiPage1.Value = 1
REPAIR_QUOTE_FORM.MultiPage1.Pages(4).SB1.SetFocus
Exit Sub
ElseIf MSGVALUE = vbYes Then GoTo loopstart
End If
End If
End If
Next SB
End If
End If
nextframe:
Next SFR
loopstart:
MsgBox "END"only here to help in debugging
End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I think you just need to get rid of the .controls in a few places.

Make

If SFR.Controls.Visible = False Then

If SFR.Visible = False Then


I thought that might be screwing you up, so I did a test with the following and it works fine.

Sub test()


Dim SFR As MSFORMS.Control

For Each SFR In UserForm1.MultiPage1.Pages(0).Controls

If TypeName(SFR) = "Frame" Then

If SFR.Visible = False Then

MsgBox SFR.Name & " not visible"

Else

SFR.Visible = True

MsgBox SFR.Name & " visible"

End If

End If


Next SFR

End Sub

I hope this helps.

Ken
 
Upvote 0
Many thanks for taking the trouble of answering this ken and it worked,:) I had tried on one of my numerous attempts with out the . controls but I must have had something else wrong as it failed but this worked a treat. thanks
 
Upvote 0

Forum statistics

Threads
1,215,492
Messages
6,125,116
Members
449,206
Latest member
burgsrus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top