Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to avoid the cursor move to next entry field. 1

Status
Not open for further replies.

wanderaround

Programmer
Jun 11, 2002
20
HK
With VFP 7, I'm writing a maintenance problem of a client database. The form consist many entry fields, the first field is the client code which should be unique. Therefore, after user enter the client code, the program will check the code to find if the code is exist in the client database. If not found, then the cursor will skip to the next entry field, otherwise, it will display a messagebox to user about duplicate entry and the cursor should keep on client code entry field. The cursor will not move to next field unless the client code is unique or user press the escape key to return to previous screen.
Now, the warning dialogue was displayed if it is a duplicated entry, but the cusor moved to next field. Also, how can I allow the user interrupt the program flow by pressing ESC key(exit the maintenance form)? Are there anyone can help?

Wanderaround
 
In the Valid of the textbox (I'll assume that is where you check for dups)
Code:
LOCAL lcValue
SELECT members
set order to tag fieldid 
STORE ALLTRIM(this.Value) TO lcValue 
IF SEEK(cvalue) && That means it already exists
  messagebox("Try another one, this one already exists!!")
  RETURN 0 && This will prevent the cursor from moving
ENDIF

But, a suggestion, why wouldn't you "auto generate" the client's code, instead of letting the user get that nessage?




Mike Gagnon
 
Mike,

Thanks for your fast response. The client code is somewhat the shortcut of a client name. So that it is easier for end-user to guess the client code easier.

According to your answer to me, how can user to terminate the entry by pressing ESC key?

Thanks

Wanderaround
 
According to your answer to me, how can user to terminate the entry by pressing ESC key?

What do you propose to happen when he hits escape?

In the Keypress you could use:
Code:
LPARAMETERS nKeyCode, nShiftAltCtrl
IF nKeyCode = 27 && Escape key is pressed.
  MESSAGEBOX("You still have to put a value") && Or whatever else you want to do here.
ENDIF



Mike Gagnon
 
in the valid even just before the dup check
if lastkey = 27 && escape
return .t. && or return 1
endif

on the property of exit button to close form, set property cancel to true. this will allow the user to escape the form by pressing the escape button. Attitude is Everything
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top