【发布时间】:2014-07-11 14:18:53
【问题描述】:
我有一个两页的用户表单,目前都正常工作(几乎)。
当我的用户点击第一页上的命令按钮时,我希望他们被发送到第二页,前提是选择了特定的选项按钮:
If ProductEnquiryYes.Value = True Then
Me.MultiPage1.Value = 1
closeForm = False
Cells(emptyRow, 20).Value = 1
End If
因此,如果选中产品查询选项 - 他们应该转到下一页。 如果未选中产品查询选项,用户应结束表单。 (标签标题将被隐藏)
但是,我现在想验证第一页上一个框架中的选项,因此必须选择每个框架内的一个选项。我快到了,但如果用户没有选择一个选项,则会出现警告,但用户会转到下一页。 (即用户收到警告为时已晚)
我需要我的代码做的是在它决定是否将我的用户发送到下一页或关闭表单之前检查选项按钮是否已经过验证。
有人可以帮忙吗?希望我的问题很清楚。
Private Sub CommandButton1_Click()
Dim emptyRow As Long
Dim closeForm As Boolean
' we assume we want the form closed unless there is a reason to go to the Extra tab
closeForm = True
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Did customer ask about product?
If ProductEnquiryYes.Value = True Then
Me.MultiPage1.Value = 1
closeForm = False
Cells(emptyRow, 20).Value = 1
End If
If ProductEnquiryNo.Value = True Then
Cells(emptyRow, 21).Value = 1
End If
'=========================================================
'Services
'=========================================================
'Balance Enquiry
If BalanceEnquiry.Value = True Then
Cells(emptyRow, 23).Value = 1
End If
'==========================================================
'Ensure Options in the frames are selected
If Me.YesCustomerOption.Value = False And Me.NoCustomerOption.Value = False Then
MsgBox "Please ensure you have selected an option for 'Is the customer an existing ASB customer?'", vbExclamation, "Failed to select an option"
Exit Sub
End If
'==========================================================
'Close Userform
If closeForm Then Unload Me
End Sub
【问题讨论】: