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!

Exit from ListBox 1

Status
Not open for further replies.

wanderaround

Programmer
Jun 11, 2002
20
HK
With VFP7, I have create a TextBox for user to input client code in a form. Also, I have create a ListBox of client database and it work as a lookup table for user to amend client record. But only Tab key can select the data and copy it to TextBox, is it possible made it the same if user press the Enter key or Esc key?
Thanks for your help.
 
wanderaround

In the .KeyPress() event of the listbox put :-

IF nKeyCode = 13 OR nKeyCode = 27
[tab]* Code to copy records
ENDI HTH

Chris [pc2]
 
Thank you. It works fine inside the client maintenance program. But when I run this program from Master Menu, it won't work. Do you know why?

Wanderaround
 
wanderaround

nKeyCode is a parameter LOCAL to the event .KeyPress() and can't be 'seen' outside the event.

You could also use on ON KEY LABEL ENTER DO procedure or ON KEY LABEL ESC DO procedure using the .When() event of a control, resetting the OKLs with ON KEY LABEL ENTER and ON KEY LABEL ESC using the .Valid() event of a control.

I don't understand the relevance of the keypress to a menu selection - if you want the routine to be the result of a menu selection, place the routine in the menu's procedure. HTH

Chris [pc2]
 
Some other issues on listbox. During the data entry, if user click on the exit button from the entry form, it won't exit from entry mode but the cursor just move to next listbox.(If I have more than one listbox inside the form.) I solve this problem by issuing a setfocus command again and again in order to end up the Entry mode. But I think it is not a normal way to do so. Anyone can help?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top