PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Lookup Tables for Entry Forms
Lookup Tables for Entry Forms
Débuté par sdaughtry, 03 juil. 2007 19:20 - 7 réponses
Posté le 03 juillet 2007 - 19:20
All,
Hoping someone in the WinDev community has already figured out how to do this. I come from the Clarion world and am absolutely spoiled by a Clarion add-on titled Prodomus PD-Lookup; information on this product and how it handles lookup tables can be found at URL: http://www.prodomus.com/PD%20Better%20Lookups/lookup.htm
A description of this product is: A double mouse click, or clicking a look up button, or pressing the AltDown key pops up a selection browse. While the field is selected, the up and down arrows enter the next or previous record. The button is skipped when moving to the next field, avoiding an unnecessary stop in data entry. You may optionally pop up the browse as soon as the user presses a key without a matching record. The lookups utilize views which may use ranges and filters. Related fields may be populated from lookups; assignments can be disabled when a record is being edited. Multiple lookups may be done using the same lookup file without aliasing. Lookups without requiring a matching record in the lookup file.
I am aware that WinDev can store last-entered text for an entry field (if toggled to do so); however, this assumes the information was entered correctly by the end-user. Forcing the use of a lookup table, that can optionally be updated by the enduser at runtime, forces data integrity.
I'm not trying to drag Clarion into the forum... I'm really wanting to use WinDev for all future projects, but the capability of PDLookup is sorely lacking in WinDev... and I'm hoping some of my Clarion/WinDev friends that visit the forum might have already gone down this path.
Cheers,
Scott

http://www.sdaughtry.com
Posté le 04 juillet 2007 - 01:21
All,
Hoping someone in the WinDev community has already figured out how to do this. I come from the Clarion world and am absolutely spoiled by a Clarion add-on titled Prodomus PD-Lookup; information on this product and how it handles lookup tables can be found at URL: http://www.prodomus.com/PD%20Better%20Lookups/lookup.htm
A description of this product is: A double mouse click, or clicking a look up button, or pressing the AltDown key pops up a selection browse.

In WinDev this is a Vision+ table (equivalent to a Clarion browse + Select button). Read up on it in the HELP. You can call it by using the KeyPressed code you see below (and see HELP too).
> While the field is selected, the up and down arrows enter the next or previous record.
While the selection browse is up? Seems the browse would have focus.
Did you mean while the edit field has focus the up and down arrow would show the next/previous value in the lookup file? If so, I'd create the edit control and link it to the Lookup file. Look thru the properties for the edit control and set Control Accessible by TAB, Assisted Input (will 'type ahead' for the user based on the values found in the Lookup table), uncheck Automatic Erase and With Selection in Display. In the Code for the edit control in the Initialization SET (Clarion speaking) the Lookup file with this command:
HReadFirst(Lookup,lookupvalue)
Then add the KeyDown event, then something like the follow code in the event:
// Checks whether down Arrow Key was pressed
VK_DOWN is int = 0x28
VK_UP is int = 0x26
VK_TAB is int = 0x09
dKey is int = VK_DOWN // Down Arrow Key
uKey is int = VK_UP
tKey is int = VK_TAB // Tab Key
// Checks whether tab Key was pressed
IF KeyPressed(tKey) THEN
..ReturnToCapture(NextField)
..// If you don't do this the tab will take place in the edit field
END
IF KeyPressed(dKey) THEN
..Edit1 = HReadNext(Lookup,lookupvalue)
..Trace(Lookup.lookupvalue)
END
// Checks whether up Arrow Key was pressed
IF KeyPressed(uKey) THEN
..Edit1 = HReadPrevious(Lookup,lookupvalue)
..Trace(Lookup.lookupvalue)
END
ReturnToCapture(MySelf)
(BTW, I got most of the code above from using the KeyPressed Wizard...)
This is roughly what you need to do... the only issue I had with test code is Edit1 gets set to "1" for some reason... even tho the Trace shows the correct read value from the Lookup file. I tried the Value and Text properties for Edit1, no luck. I remember there was something that needed to be set, but I can't remember... Can someone point out my error here?
Once you get the correct value in Edit1 and tab out, save Edit1 to the appropriate field in the record you are editing.
The button is skipped when moving to the next field, avoiding an unnecessary stop in data entry.

In the button properties that calls the Vision+ table uncheck the Accessible by TAB check box. The button will be skipped as you tab through the controls but still be accessible by mouse.
>> You may optionally pop up the browse as soon as the user presses a key without a matching record.
In the When Modified event for the Edit control, for each keystroke check to see if there is a value in the Lookup file that would match by using:
Res = HReadSeek(lookup,lookupvalue)
If Res = false Then
..Clear the Edit field
..Open the Vision+ table and select/assign the correct value
End
The lookups utilize views which may use ranges and filters. Related fields may be populated from lookups; assignments can be disabled when a record is being edited. Multiple lookups may be done using the same lookup file without aliasing. Lookups without requiring a matching record in the lookup file.

I haven't had time to figure it out yet but I'm sure it's doable. For instance depending on variable values you can set at runtime an HFilter on the Lookup in the Edit controls Initiation (instead of HReadFirst(Lookup...) use any of the various HFilterXXX commands. Upon tab out assign Filename.Field = Lookup.LookupValue for all related fields, etc...
I hope I've given you some ideas to start out with, and while I am sure it's not perfect it didn't cost you ProDomus's $149 either . If you have trouble with the code or the concepts are not clear continue to post here so everybody learns/can participate in the discussion.
Art
Posté le 04 juillet 2007 - 08:18
Art,
Thank you for taking a healthy stab at this brainteaser . The up/down arrow keys, when placed inside of the data entry field, will automatically place the contents of the lookup table into the entry field - uparrow will decrement back through the lookup table and downarrow will increment. Typing alphanumeric characters inside of the data entry field will autofill from the lookup table and place the closest value into the data entry field.
I believe that Phil still has an example Clarion application with the PDLookup template applied to get the full effect... if he doesn't I can quickly put something together for a WinDev expert to play with.
I would gladly pay for a WinDev supercontrol that I could simply drop onto a data entry form, tell the control what data entry field and lookup table procedure to use, and get rock-n-rollin.... my customer base swears by PDLookup (and so do I), as using 'normal' lookup tables that you have to take your hands off of the keyboard to mouseclick on things greatly slows down data entry - it completely revolutionized my database applications!
Hopefully some other WinDev programmers will look at this thread and give it a thought... thank you very much for your reply...
Cheers,
Scott
All,
Hoping someone in the WinDev community has already figured out how to do this. I come from the Clarion world and am absolutely spoiled by a Clarion add-on titled Prodomus PD-Lookup; information on this product and how it handles lookup tables can be found at URL: http://www.prodomus.com/PD%20Better%20Lookups/lookup.htm
A description of this product is: A double mouse click, or clicking a look up button, or pressing the AltDown key pops up a selection browse.
In WinDev this is a Vision+ table (equivalent to a Clarion browse + Select button). Read up on it in the HELP. You can call it by using the KeyPressed code you see below (and see HELP too).

While the field is selected, the up and down arrows enter the next or previous record.
While the selection browse is up? Seems the browse would have focus.

Did you mean while the edit field has focus the up and down arrow would show the next/previous value in the lookup file? If so, I'd create the edit control and link it to the Lookup file. Look thru the properties for the edit control and set Control Accessible by TAB, Assisted Input (will 'type ahead' for the user based on the values found in the Lookup table), uncheck Automatic Erase and With Selection in Display. In the Code for the edit control in the Initialization SET (Clarion speaking) the Lookup file with this command:
HReadFirst(Lookup,lookupvalue)
Then add the KeyDown event, then something like the follow code in the event:
// Checks whether down Arrow Key was pressed
VK_DOWN is int = 0x28
VK_UP is int = 0x26
VK_TAB is int = 0x09
dKey is int = VK_DOWN // Down Arrow Key
uKey is int = VK_UP
tKey is int = VK_TAB // Tab Key
// Checks whether tab Key was pressed
IF KeyPressed(tKey) THEN
..ReturnToCapture(NextField)
..// If you don't do this the tab will take place in the edit field
END
IF KeyPressed(dKey) THEN
..Edit1 = HReadNext(Lookup,lookupvalue)
..Trace(Lookup.lookupvalue)
END
// Checks whether up Arrow Key was pressed
IF KeyPressed(uKey) THEN
..Edit1 = HReadPrevious(Lookup,lookupvalue)
..Trace(Lookup.lookupvalue)
END
ReturnToCapture(MySelf)
(BTW, I got most of the code above from using the KeyPressed Wizard...)
This is roughly what you need to do... the only issue I had with test code is Edit1 gets set to "1" for some reason... even tho the Trace shows the correct read value from the Lookup file. I tried the Value and Text properties for Edit1, no luck. I remember there was something that needed to be set, but I can't remember... Can someone point out my error here?
Once you get the correct value in Edit1 and tab out, save Edit1 to the appropriate field in the record you are editing.
The button is skipped when moving to the next field, avoiding an unnecessary stop in data entry.
In the button properties that calls the Vision+ table uncheck the Accessible by TAB check box. The button will be skipped as you tab through the controls but still be accessible by mouse.

You may optionally pop up the browse as soon as the user presses a key without a matching record.
In the When Modified event for the Edit control, for each keystroke check to see if there is a value in the Lookup file that would match by using:

Res = HReadSeek(lookup,lookupvalue)
If Res = false Then
..Clear the Edit field
..Open the Vision+ table and select/assign the correct value
End
The lookups utilize views which may use ranges and filters. Related fields may be populated from lookups; assignments can be disabled when a record is being edited. Multiple lookups may be done using the same lookup file without aliasing. Lookups without requiring a matching record in the lookup file.
I haven't had time to figure it out yet but I'm sure it's doable. For instance depending on variable values you can set at runtime an HFilter on the Lookup in the Edit controls Initiation (instead of HReadFirst(Lookup...) use any of the various HFilterXXX commands. Upon tab out assign Filename.Field = Lookup.LookupValue for all related fields, etc...

I hope I've given you some ideas to start out with, and while I am sure it's not perfect it didn't cost you ProDomus's $149 either . If you have trouble with the code or the concepts are not clear continue to post here so everybody learns/can participate in the discussion.
Art



http://www.sdaughtry.com
Posté le 04 juillet 2007 - 09:35
Hi Scott,
The Vision tables are old5.5 RAD concepts.
The way we tend to implement this sort of functionality (although not identical) is via the use of PopUp windows. In short, you define a PopUp window (which may go from extremely straightforward to pretty complex with even advanced lookupfunctionality on e.g. a seperate tab page) and link it to a control on your window. Either you create a fill-in control as a combo where clicking the drop-down button will open the PopUp window (see properties) or you create a seperate button next to the fill-in control that opens the PopUp window.
The nice thing is that such a lookup will not open a new modal (boohhhh) window, but a window that hoovers over the current window like a tooltip window.
You can build such a PopUp window in no-time for each entity you would like to do searches on and re-use it anywhere throughout your app. And the nice thing is you can make it as advanced as you want where the PopUp may even exist of a window with different tabs, tables, treeviews, etc...
You can build in the requested key functionality by catching the pressed keys and writing specific behaviour code. You might generalise this in a class.
That would be my advice to build even nicer lookup tools than what you have seen until now in your other tool.
In the online help, you can find all related help on PopUp windows and their specific functions by searching on the PopUp keyword.
Cheers,
P.
Posté le 04 juillet 2007 - 10:17
This sounds like this could be turned into a nice tutorial for Ken Knight.
Ken.... are you listening?
Glenn Rathke
Posté le 04 juillet 2007 - 10:17
Hi Scott,
The Vision tables are old5.5 RAD concepts.
The way we tend to implement this sort of functionality (although not identical) is via the use of PopUp windows. In short, you define a PopUp window (which may go from extremely straightforward to pretty complex with even advanced lookupfunctionality on e.g. a seperate tab page) and link it to a control on your window. Either you create a fill-in control as a combo where clicking the drop-down button will open the PopUp window (see properties) or you create a seperate button next to the fill-in control that opens the PopUp window.

Peter, is this new in WD11? My understanding of PopUp's are what you get with a right-click... "Export to Excel" and "View Columns" type of stuff, nothing as complicated as what you describe.
Or maybe I'm missing something?
Thx,
Art
Posté le 04 juillet 2007 - 11:25
Peter, is this new in WD11? My understanding of PopUp's are what you get with a right-click... "Export to Excel" and "View Columns" type of stuff, nothing as complicated as what you describe.
Or maybe I'm missing something?
Thx,
Art

No, it has been there forever since version 8. I'll provide some samples with screen shots on this forum later today.
Cheers,
P.
Posté le 04 juillet 2007 - 12:34
Peter, is this new in WD11? My understanding of PopUp's are what you get with a right-click... "Export to Excel" and "View Columns" type of stuff, nothing as complicated as what you describe.
Or maybe I'm missing something?
Thx,
Art
No, it has been there forever since version 8. I'll provide some samples with screen shots on this forum later today.

Cheers,
P.

Thank you! I'm with you, I don't much like the Vision+, but I've always thought it was a necessary evil.
Art