Go to a control after an error

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

Guest

H

I want to test a field in my form.

if it has an error i want to display a msgbox and go to that control to recorrect my entry

Although i made like tha

If me.F1 <= 0 then Msgbox"Error. Correct it , please.", VbOkOnl
DoCmd.GotoControl "F1
Endi

it allways go to the next textbox according to the tab order

it's this wrong or is there any other problem that is missing

Thanks for your hel

Zeca
 
Where is this code? Is it in the afterUpdate event? or elsewhere? you need
to put it in the afterupdate event or try using the validation property.
 
Zeca

Just another thought...

Have you tried using:

Me!F1.SetFocus

to see if it works any differently?

You didn't mention which event firing you used to run this code -- ?in the
BeforeUpdate?

Your test is for a numeric value less than or equal to 0 -- can the user
enter ... nothing? (a null) Or a space? Or a text string?
 
hi Jeff Boyc

There is any event firing

i just enter data on this textbox (Default Value is 0 (zero)) . it's a number (double) .

After update i want to fire the msgbox and set focus AGAIN on F1 and don't let it to go
to the next field as it happens now

The user is not allowed to enter nothing (a null) as you mentioned or a strin

Thanks for your help and i will be looking for your hel

Best Regard
Zeca
 
I have done this and it works in my app.
I place the code "on Exit"event like

If Me![F1].text<=0 then
MsgBox.....
Cancel = True
Me![f1].SetFocus
End If

Bob
-----Original Message-----
HI

I want to test a field in my form.

if it has an error i want to display a msgbox and go to
that control to recorrect my entry.
 
Did you check my answer under Bob?
Did it work?
-----Original Message-----
Hi kailash

i put the code on an After Update event.

i have this textbox that is bounded to a field in my
table. Default value = 0 and is a number Field (Double)
After i type some number (imagine -1.50) it fires the
error message and should return to the F1 textbox
in order to correct the value.

I tried allready a lot of things. But it keeps going to the next tab order field.
in order to correct the value i have to tab to the
textbox and out the correct value.
 
Hi Bo

Thanks for your hel

i will try your code and see
1 question

The code you wrote prevents the null situation

Thanks agai
Zeca
 
Thanks a lot Bob

it worked

1 Question : i am putting a msgbox VbOkOnly.

Woudln't be better to place another tipe like VbOKCancel?

What would change in the code u send to me?

Best regards

Zeca
 
Back
Top