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