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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use shortcut menu in text box?

Status
Not open for further replies.

alisaif

ISP
Apr 6, 2013
418
AE
Hi,

I have a data entry form in which I want to put some check in Valid Event or Lost Focus Event of text box of Item Code or Customer Code to check whether the code exist in master file, if it exist the users can go ahead otherwise it will ask for search. But in the same text box in right click event I put shortcut menu as follows

Code:
DEFINE POPUP shortcut SHORTCUT RELATIVE FROM MROW(),mcol()
DEFINE BAR 1 OF shortcut PROMPT "\<1. Item Search" FONT "Tahoma",10
DEFINE BAR 2 OF shortcut PROMPT "\<2. Item-Wise Sales" 
DEFINE BAR 3 OF shortcut PROMPT "\<3. Sales Order List"
DEFINE BAR 4 OF shortcut PROMPT "\<4. Despatch Order list"
DEFINE BAR 5 OF shortcut PROMPT "\<5. Delivery Challans"
DEFINE BAR 6 OF shortcut PROMPT "\<6. Sales Invoices"
DEFINE BAR 7 OF shortcut PROMPT "\-"
DEFINE BAR 8 OF shortcut PROMPT "\<7. Item Price"
ON SELECTION BAR 1 OF shortcut do form finditem
ON SELECTION BAR 2 OF shortcut do form custpx
ON SELECTION BAR 3 OF shortcut do form ViewSo
ON SELECTION BAR 4 OF shortcut do form abc3
ON SELECTION BAR 5 OF shortcut do form abc4
ON SELECTION BAR 6 OF shortcut do form abc1
ON SELECTION BAR 8 OF shortcut do form abc1

ACTIVATE POPUP shortcut

What I want is the user can avail any option during entry but what happen if the user do right click it is performing valid event or lost focus event.

How can I sort out this problem, please guide me..

Thanks

Saif
 
Several solutions:

Use a combobox instead of a free entry textbox, so the user can only select item or customer code. The combobx can have the code and item/customer name, so the choice is more natural. If there are too many records, first there is incremental search, then you can use double click to open a search form resulting in a picklist and return with one selected code.

Put validation into a central overal record validation instead of using valid event.

You can't solve that technnical, a popup is a seperate windw, so there is no way to avoid valid. But that's another reason to not use this kind of harsh direct field validation. There are many more reasons to make that validation inside a central method, you can put it into business logic also controlling a data access class, you don't put business logic inside the UI, even more so not into single controls.

This is not really business rules, but referential integrity, but no matter what rules, you better centralize their check.

If you detect a broken rule, you can highlicht all controls with wrong data colorwise and set focus to one of them.

Bye, Olaf.
 
Thanks Olaf for the nice feedback, we have around 33,000 item codes, so it is very difficult to select the record from combo box by keeping incremental search. If I select combo box style 0 instead of 2 will it give me the required result? Or apart from it Can I use Alt+(any key) command to activate the popup or can I use f1-f12 keys which I was using in Dos Program. will it check the code in valid/lost focus event?

Thanks

Saif
 
Saif, you definitely don't want to use as combo box if you have 33,000 items. It simply won't work, even if you use an incremental search or any other technique for finding the item.

I think you should stay with the textbox. But move the menu choices to a separate control. In other words, something like this:

1. The user enters the item code in the textbox.

2. In the LostFocus of the textbox, do the search. If the item is found in the master file, populate a label with the name of the item (this gives the user a visual confirmation that they have entered the correct code.) If the item is not found, display an message.

3. If the item is found, the user moves to the next control(s), from which they choose the next action. This might be a listbox, or a set of buttons, or something similar. Either way, the user uses the control to initiate the item-wise sales, the sales order list, or whatever. This control would only be enabled if the item was found in the master file.

To make it a bit easier for the user, you could use auto-complete for the text box. That way, if the user has previously entered the same code, they will only have to type the first few characters this time.

This is just one possibility. The point is to look for a solution to the wider problem, rather than trying to focus on the original question.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 

Well, I said

If there are too many records, first there is incremental search, then you can use double click to open a search form resulting in a picklist and return with one selected code.

so a) for eg 1000 records incremental search still is fine, but b) I'd then just offern neither textbox nor combobox but calling a search form via a readonly textbox + button.

Bye, Olaf.
 
Yes, Mike,

1. The user enters the item code in the textbox.

2. In the LostFocus of the textbox, do the search. If the item is found in the master file, populate a label with the name of the item (this gives the user a visual confirmation that they have entered the correct code.) If the item is not found, display an message.

3. If the item is found, the user moves to the next control(s)


I did it till this point. But as far as move the cursor to Options for statement, it is not possible because it is a batch-wise entry and the user enters 60-75 records from a single LPO and he has to finish multiple LPOs within 1 to 2 hours because of delivery in morning session.

So, the cursor from the Itemcode textbox should move immediately to Quantity column(text field).

I am sending you the image of the entry, please go through it.

Thanks

Saif
 
the cursor from the Itemcode textbox should move immediately to Quantity column(text field).

That doesn't change the basic point I was trying to make. What I'm suggesting is that you shouldn't use a context menu in the text box, because at the point at which the user is working in the text box, you don't yet know if the code is valid.

The basic principle is to let the user enter the code. Then check that it's valid and display some sort of confirmation or feedback. Then let the user decide what to do next.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top