Prompt Again on bad input

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

Guest

I have a text box with a subroutine event that runs "after update".

The subroutine checks for the validity of the input, and if it is bad, it
blanks the input value.

What I can't find is how to go back to the input text box so the user can
put in a new value. Instead, it goes to the next text box.
I have tried exit sub and me.requery, together and alone, and I cannot find
anything in help to indicate how to prompt again without having to create a
subroutine event for "Before update" or "On entry" or something.

Clues would be appreciated.
Thanks in advance.
 
If you don't want to let the user out until they supply a different value,
use the BeforeUpdate event of the control.

Just cancel the event. Everything else is done for you.
 
Hi PhotoFinish
write your validation function in a module with a return value of, for
example, 1 for a good value and 0 for a bad value.
Make a call to the function in the validation rule of the text box so till
the return value is good the prompt stays in the text box.
So that in the validation rule you can write: val_func(parameters)=1

HTH Paolo
 
Thanks, Allen, but I am not sure what you mean "Just cancel the event". Can
you clarify a bit? And I gather you are indeed saying that I have to write a
"BeforeUpdate" event that I would then gosub to?
 
PhotoFinish said:
Thanks, Allen, but I am not sure what you mean "Just cancel the event".
Can
you clarify a bit? And I gather you are indeed saying that I have to
write a
"BeforeUpdate" event that I would then gosub to?

PMFJI ... Allen means to put your code in the form's Before Update event.
If your condition is not satisfied then cancel the event:

If SomeCondition = True Then
Do something
Else
Do something else
Cancel = True
End If

HTH - Keith.
www.keithwilby.com
 
Thanks, this helps conceptually. But I remain thick. If I put bad data in,
it traps the bad data and returns me to the text box -- good. It doesn't
wipe out the bad text, but I can live with that. (I tried me.fldr1 = "", but
got an error, so I took it out.) But now, if I put in any bad value, it
tells me I'm stupid and to do it over(as desired), but if I put in a good
value, nothing. It just sits. I tried adding an after_update process, I
tried taking it away again, it never goes forward. (I put a msgbox in the
after_update, which never displays.)

ALmost there -- one last connecting piece, please?
 
Here is a small sample of code that works for me (Access 2003)

Private Sub fSubject_BeforeUpdate(Cancel As Integer)

If Len(Me.fSubject) < 2 Then
Cancel = True
MsgBox "Enter a longer title"
Me.fSubject.SelStart = 0
Me.fSubject.SelLength = 32000
End If

End Sub

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
AH-HA! Ok. Thanks, everybody. I don't typically use BeforeUpdate, or use
Cancel. Mostly I work with afterupdate stuff. Plus I needed to fix a value
that didn't reset as I guess I thought it would. So, Happy, happy. (And a
bit sheepish).

Thanks again.
 
Back
Top