How to get the cursor back to the TxtBox?

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

Guest

Hi Everyone,

I write a Public Function to check my input TxtBoxes in order to prevent
input error. I put this check in the AfterUpdate event of the TxtBox. When an
error is found and exit function, the cursor jumps to the next object in the
form, my problem is how to get the cursor back to that TxtBox?
 
Jeff was zeer hard aan het denken :
Hi Everyone,

I write a Public Function to check my input TxtBoxes in order to prevent
input error. I put this check in the AfterUpdate event of the TxtBox. When an
error is found and exit function, the cursor jumps to the next object in the
form, my problem is how to get the cursor back to that TxtBox?

<object>.setfocus
 
Jeff said:
I write a Public Function to check my input TxtBoxes in order to prevent
input error. I put this check in the AfterUpdate event of the TxtBox. When an
error is found and exit function, the cursor jumps to the next object in the
form, my problem is how to get the cursor back to that TxtBox?


Use the BeforeUpdate event to verify the data before it
becomes the control's value. BeforeUpdate even has a Cancel
argument that will also prevent the focus from moving.
 
Dear Gijs,

Because this is a Public Function, there are many TxtBoxes will refer to it.
Therefore, the TxtBoxes' names will be different. I don't know what I should
put for the <object> in <object>.SetFocus?

Jeff

"Gijs Beukenoot" 來函:
 
Dear Marshall,

I have tried to put this check by referring to the Public Function with
Cancel = True if error is found in the BeforeUpdate event, but the cursor
still jumps to the next control. If I put If Error is found Then Cancel =
True & End If directly in the BeforeUpdate event, it works. What I want to do
is write a perfect Public Function and just simply refer to it every time I
need it. Can you tell me more?

"Marshall Barton" 來函:
 
Jeff stelde de volgende uitleg voor :
Dear Marshall,

I have tried to put this check by referring to the Public Function with
Cancel = True if error is found in the BeforeUpdate event, but the cursor
still jumps to the next control. If I put If Error is found Then Cancel =
True & End If directly in the BeforeUpdate event, it works. What I want to do
is write a perfect Public Function and just simply refer to it every time I
need it. Can you tell me more?

"Marshall Barton" ��H

You're usinga macro now? Switch to VB-code for that property. Select
before-update, press the three dots at the end, choose program (or VBA
(I have a localized version so I'm not sure what it's called in
English)) and then, in that code, type
Cancel = (Not <your function>)
Your function should return TRUE when the data is correct...
 
Dear Gijs,

I finally solve my problem, Thank you very much.

Jeff

"Gijs Beukenoot" 來函:
 
Back
Top