loststudent
New Member
- Joined
- Jan 25, 2018
- Messages
- 7
Hello everyone!
I have a MessageBox in my application that asks whether the user wants to add a new product to the order or not. If I press 'No', it closes. When I press 'Yes', it does what it's supposed to do, lets me add another product, and so on. The problem is that once I press no, the amount of MessageBoxes I get is the number of times I pressed 'Yes' before that. How could I solve this?
The code is:
'Show MessageBox asking user if they want to add more products to the order
Private Sub Addmoreproducts()
'Declare the msg (message) and ans (answer) variables
Dim msg, ans
Do
Unload UFAddStock
Unload UFUpdateStock
msg = "Add more products to the order?"
ans = MsgBox(msg, vbYesNo)
'If answer is Yes, then close this UserForm and open the UserForm for adding more products
If ans = vbYes Then
Unload UFAddStock
UFUpdateStock.Show
End If
'If answer is No, then close all open UserForms and return to the sheet
If ans = vbNo Then Exit Do
Unload UFAddStock
Unload UFUpdateStock
'Loop for MessageBox until answer is No
Loop Until ans = vbNo
End Sub
Thank you in advance!
I have a MessageBox in my application that asks whether the user wants to add a new product to the order or not. If I press 'No', it closes. When I press 'Yes', it does what it's supposed to do, lets me add another product, and so on. The problem is that once I press no, the amount of MessageBoxes I get is the number of times I pressed 'Yes' before that. How could I solve this?
The code is:
Code:
Private Sub Addmoreproducts()
'Declare the msg (message) and ans (answer) variables
Dim msg, ans
Do
Unload UFAddStock
Unload UFUpdateStock
msg = "Add more products to the order?"
ans = MsgBox(msg, vbYesNo)
'If answer is Yes, then close this UserForm and open the UserForm for adding more products
If ans = vbYes Then
Unload UFAddStock
UFUpdateStock.Show
End If
'If answer is No, then close all open UserForms and return to the sheet
If ans = vbNo Then Exit Do
Unload UFAddStock
Unload UFUpdateStock
'Loop for MessageBox until answer is No
Loop Until ans = vbNo
End Sub
Code:
Thank you in advance!