MsgBox Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a field called WK1. It is a number field. I would like to impose a
messagebox when a user enters an amount that is > than 4 digits in length. I
want the messagebox to alert the user that the amount may be wrong and if
they choose No, the amount will be removed from WK1 and the WK1 field will
receive focus again. If the user chooses Yes, then the cursor will move to
the next field leaving the keyed amount.

I can call up the messagebox, but I can't get it to respond correctly. Any
help would be greatly appreciated.
 
In the Before Update event of WK1:

'Convert the number to a string and checks the length of it
If Len(Cstr(Me.WK1)) > 4 Then
If MsgBox("Is This Number Correct", vbYesNo + vbQuestion) = vbNo Then
'Empty the text box
Me.Wk1 = Null
'Cancel the Control Update and leave the focus on the control
Cancel = True
End If
End If

Len(Cstr(Me.WK1)) Converts the number to a string and checks the length of it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top