How to return the cursor to the calling field?

  • Thread starter Thread starter spidermanuk
  • Start date Start date
S

spidermanuk

Access2000.

I do not want to use Access' own 'Validation' as it returns a msgbo
which I do not want.

I have written my own validators in 'Text1.Afterupdate', however, whe
the Afterupdate runs, IF the tested data is invalid I want it simply t
beep and have the cursor return to the Text1 field.

If I try Text1.SetFocus I get an error to 'save data before GOT
comand..'.

Sample Text1.AfterUpdate code:
If (Text1.value = "valid data") Then
'do nothing and allow the form to return to the next field
ELSE
'stay on the current field? to allow data to be rekeyed
Text1.SetFocus
Endif


Help

Spider.


:confused
 
spidermanuk said:
Access2000.

I do not want to use Access' own 'Validation' as it returns a msgbox
which I do not want.

I have written my own validators in 'Text1.Afterupdate', however, when
the Afterupdate runs, IF the tested data is invalid I want it simply to
beep and have the cursor return to the Text1 field.

If I try Text1.SetFocus I get an error to 'save data before GOTO
comand..'.

Sample Text1.AfterUpdate code:
If (Text1.value = "valid data") Then
'do nothing and allow the form to return to the next field
ELSE
'stay on the current field? to allow data to be rekeyed
Text1.SetFocus
Endif

Validation belongs in BeforeUpdate, not AfterUpdate (think about it).
BeforeUpdate has a Cancel argument that you can set to True when the validation
fails. This means the control never loses focus so there is no need to set it
back.
 
Back
Top