What I'm trying to achieve is that when you click yes the first user form should appear, if no the other user from should show:
Private Sub btnDataSecurity_Click()
Question = MsgBox("Is this client specific", vbYesNo)
If vbYes Then
With DBUnilever
.StartUpPosition = 2
.Top = (Application.Height / 2)
.Left = (Application.Width / 2)
.Show
End With
Unload Me
Else
With DataBreach
.StartUpPosition = 2
.Top = (Application.Height / 2)
.Left = (Application.Width / 2)
.Show
End With
End If
Unload Me
End Sub
The if-else function is not working for me. I don't know what went wrong. Can someone please help me with this?
Consider replacing:
If vbYes Then
with:
If Question = vbYes Then
(there may be other errors in the posted code)
As Gary's Student said, you should replace: If vbYes Then
with If Question = vbYes Then
. Since you posted the whole Sub and there's no Dim
for Question
, make sure that you're declaring it (as an Integer
, 'cause that's the return type of MsgBox
) before it's usage.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.