SetFocus

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

Guest

I've got a simple code that compares with a value and if exceeded, to pop a
warning and then setfocus on the same field to allow the user to amend the
figure. However, the setfocus doesn't seem to work:

If Val(txtWeightageTemp) + Val(txtTotalWeight) - bytWeightage > 100 Then
MsgBox "Your total weightage for this subject has been exceeded.
Please re-enter.", vbOKOnly
Me.txtWeightageTemp = ""
Me.txtWeightageTemp.SetFocus
End If

I've tried something similar before and it always works. Am I missing
something somewhere? Thanks.
ck
 
Where are you doing this? If you are doing it in the field's Exit event,
then the event fires before the exit. It performs all the tasks listed,
then exits (goes to the next field). You would need to stop it from
exitting. This id done by inserting the line...

cancel = true

....before the end of your procedure.


Rick B
 
I've got a simple code that compares with a value and if exceeded, to pop a
warning and then setfocus on the same field to allow the user to amend the
figure. However, the setfocus doesn't seem to work:

If Val(txtWeightageTemp) + Val(txtTotalWeight) - bytWeightage > 100 Then
MsgBox "Your total weightage for this subject has been exceeded.
Please re-enter.", vbOKOnly
Me.txtWeightageTemp = ""
Me.txtWeightageTemp.SetFocus
End If

I've tried something similar before and it always works. Am I missing
something somewhere? Thanks.
ck

what is not working?

if the if... is not working because one of the fields is Null then use
NZ()
 
Rick, it's in the AfterUpdate event of that particular field. What happens is
that after the msgbox pops up and I click OK, the focus will be on another
field instead of the field that I want. Thanks.
ck
 
Andi, what is not working is the setfocus command. I've set the focus on the
field that I wanted the user to amend but it always end up on another field.
Thanks.
ck
 
Andi, what is not working is the setfocus command. I've set the focus on the
field that I wanted the user to amend but it always end up on another field.
Thanks.
ck
I see out of the answer to Rick taht your messagebox is poping up,
this was waht I wanted to know.

Check your forms-Code if you there is another setfocus somewhere
 
Back
Top