Setfocus

libby32

Registered User.
Local time
Today, 11:01
Joined
Mar 6, 2003
Messages
42
I have a subform that checks a value in the main form. If the value is greater I get a messagebox box saying so - this works o.k. but now I want to setfocus back to this same text box and put the value back to zero before the user can change it or move on. Here is what I have but it just moves on to the next text box on the form...

If MedfrWharf > [Forms]![frmAddtoMaturing-Port au Choix]![MedTubsLeft] Then
If MsgBox("# Tubs taken can't be more than # tubs on wharf!", vbOKCancel, "Wrong # Medium Containers") = vbCancel Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
End If
 
<Name textbox>.Setfocus instead of DoCmd
<Name textbox>.text = "0"
 
What event are you using? BeforeUpdate?

If so you can cancel the update.

You don't even need to use an if statement:

MsgBox("# Tubs taken can't be more than # tubs on wharf!", vbOKOnly, "Wrong # Medium Containers")

Cancel = True

Forms!MainForm!SubForm.Form!Textbox.Undo
 
Oops... forgot you had two if statements. I meant you didn't need the one for the msgbox.
 

Users who are viewing this thread

Back
Top Bottom