MsgBox

y481184

Board Regular
Joined
Aug 1, 2003
Messages
137
To ensure valid data, I have created a message box that will appear if an incorrect value is inserted into one of my forms. However, after the msgbox appears, and I click OK, the focus does not return to the point of error. Instead, the second form procedes to be displayed. Any Ideas?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

y481184

Board Regular
Joined
Aug 1, 2003
Messages
137
Case Else
MsgBox "You Have Entered an Invalid Vendor Code", vbCritical, "Invalid Vendor"
txtVenCode.SetFocus
End Select
 
Upvote 0

WillR

Well-known Member
Joined
Feb 18, 2002
Messages
1,143
sorry, but that snippet of your code does not really tell me why this is not working as you expect. Can you post the relevant section of code ... cheers
 
Upvote 0

TryingToLearn

Well-known Member
Joined
Sep 10, 2003
Messages
730
Case Else
MsgBox "You Have Entered an Invalid Vendor Code", vbCritical, "Invalid Vendor"
txtVenCode.SetFocus
End Select

As Will said, it's easier if you have more code posted, but for a guess I would:


Case Else
MsgBox "You Have Entered an Invalid Vendor Code", vbCritical, "Invalid Vendor"
txtVenCode.SetFocus
exit sub
End Select
 
Upvote 0

Forum statistics

Threads
1,186,921
Messages
5,960,575
Members
438,486
Latest member
ncc84330

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
Top