Set Focus after message box closes

sashapixie

Registered User.
Local time
Today, 03:37
Joined
Sep 30, 2015
Messages
27
Hi All

I have the following code which opens a message box:

Private Sub Pick_Ship_Quantity_AfterUpdate()
Dim CurrentStock As Long
Dim SelectedStock As Long
CurrentStock = Me.Transaction_Item.Column(2)
SelectedStock = Me.Pick_Ship_Quantity
If Me.Dirty = True Then Me.Dirty = False
If CurrentStock < SelectedStock Then
MsgBox "You only have a stock level of " & Me.Transaction_Item.Column(2) & " Items in your inventory", vbQuestion, "Inventory Information"
Cancel = True
Me.Pick_Ship_Quantity.SetFocus
End If
End Sub

However I cannot get the SetFocus to run once the message box is closed.

I want the message box to run after the field is updated, therefore the code will run when you tab or select away from the cell. As this message box has a criteria if the criteria is true I want the message box to appear and for the field to be in focus again so the employee can put in a correct figure.

Any help is appreciated.

Thanks
 
Cancel = True

is only valid in the before update event, which is where validation should be.
 

Users who are viewing this thread

Back
Top Bottom