Selection List Programming in Visual DataFlex
Programming a selection [lookup] list in VDF12 can be enhanced with the use of an “enter new” button that allows you to enter a new parent record, and have it “fall thru” the selection list into the data entry program or report.
The selection list has been made such an amazingly easy task by Data Access Worldwide, where a lookup (as pictured below) can be created in just a few clicks and keystrokes.
The Selection List [stock] from the Order Entry Sample Example VDF 12.1 …
Programming a selection [lookup] list in VDF12 can be enhanced with the use of an “enter new” button that allows you to enter a new parent record, and have it “fall thru” the selection list into the data entry program or report.
The selection list has been made such an amazingly easy task by Data Access Worldwide, where a lookup (as pictured below) can be created in just a few clicks and keystrokes.
The Selection List [stock] from the Order Entry Sample Example VDF 12.1 …
The second SL pictured is a great candidate for the addition of an “add new” button.
End result desired pictured here:
End result desired pictured here:
… and the add new dialog:
What follows is;
[1] The code from the Modal Dialog
[2] The code from the Selection List
(In VDF 12.1 code)
//====================================//
// dbModalPanel = Popup Dialog for entering new sales person
Use DFClient.pkg
Use SalesP.DD
Use Customer.DD
Use OrderHea.DD
Use DFEntry.pkg
Object SalepAddNewDialog is a dbModalPanel
Property Boolean pbOK
Property RowID priRowID
Object oSalesp_DD is a Salesp_DataDictionary
End_Object
Set Main_DD to oSalesp_DD
Set Server to oSalesp_DD
Set Label to "Add or Edit Sales Person"
Set Size to 83 308
Set Location to 2 2
Set Border_Style to Border_Dialog
Set Auto_Clear_DEO_State to False // no clear on save
Procedure Popup
Set pbOk to False
Send Clear of oSalesp_DD
Forward Send Popup
End_Procedure
Object oSalesP_ID is a dbForm
Entry_Item SalesP.ID
Set Location to 9 91
Set Size to 13 42
Set Label to "Sales Person ID:"
End_Object
Object oSalesP_Name is a dbForm
Entry_Item SalesP.Name
Set Location to 23 91
Set Size to 13 156
Set Label to "Sales Person Name:"
Set Label_Col_Offset to 2
Set Label_Justification_Mode to JMode_Right
End_Object
Object oOK_btn is a Button
Set Label to C_$OK
Set Location to 44 185
Set Default_State to True
Procedure OnClick
Handle hServer
RowID riRowID
Move oSalesp_DD to hServer
Send Request_Save
If (Should_Save(hServer)) Procedure_Return
If (not(Current_Record(hServer))) Begin
Send Info_Box "Please Find Or Enter A New Sales Person ~ Then Click Ok"
Procedure_Return
End
Get CurrentRowID of hServer to riRowID
Set priRowID to riRowID
Set pbOK to True
Send Close_Panel
End_Procedure
End_Object
Object oCancel_btn is a Button
Set Label to C_$Cancel
Set Location to 44 243
Procedure OnClick
Send Close_Panel
End_Procedure
End_Object
On_Key Key_Alt+Key_O Send KeyAction of oOk_btn
On_Key Key_Alt+Key_C Send KeyAction of oCancel_btn
End_Object
//====================================//
// Selection List augmented only for the add new button:
Use DFClient.pkg
Use DFSelLst.pkg
Use Windows.pkg
Use SalesP.DD
Use SalepAddNewDialog.dg
CD_Popup_Object SalesP_sl is a dbModalPanel
Set Minimize_Icon to False
Set Label to "Sales People List"
Set Size to 118 265
Set Location to 4 5
Set piMinSize to 97 174
Object SalesP_DD is a SalesP_DataDictionary
End_Object // Salesp_DD
Set Main_DD to SalesP_DD
Set Server to SalesP_DD
Object oSelList is a dbList
Set Main_File to SalesP.File_Number
Set Ordering to 1
Set Size to 71 248
Set Location to 6 6
Set peAnchors to anAll
Set pbHeaderTogglesDirection to True
Begin_Row
Entry_Item SalesP.ID
Entry_Item SalesP.Name
End_Row
Set Form_Width 0 to 40
Set Header_Label 0 to "ID"
Set Form_Width 1 to 200
Set Header_Label 1 to "Sales Person Name"
End_Object // oSelList
Object oOK_bn is a Button
Set Label to "&Ok"
Set Location to 81 97
Set peAnchors to anBottomRight
Set Default_State to True
Procedure OnClick
Send OK To oSelList
End_Procedure
End_Object // oOK_bn
Object oCancel_bn is a Button
Set Label to "&Cancel"
Set Location to 81 151
Set peAnchors to anBottomRight
Procedure OnClick
Send Cancel To oSelList
End_Procedure
End_Object // oCancel_bn
Object oSearch_bn is a Button
Set Label to "&Search..."
Set Location to 81 205
Set peAnchors to anBottomRight
Procedure OnClick
Send Search To oSelList
End_Procedure
End_Object // oSearch_bn
Object oAddNew_bn is a Button
Set Label to "&Add New"
Set Location to 81 8
Set peAnchors to anBottom
Procedure OnClick
Handle hModalDialog
Move (SalepAddNewDialog(Self)) to hModalDialog
Send Popup of hModalDialog
If (pbOk(hModalDialog)) Begin
Send FindByRowID of (Server(Self)) Salesp.File_Number (priRowID(hModalDialog))
Send Display of oSelList
Send Ok of oSelList
End
End_Procedure
End_Object
On_Key Key_Alt+Key_A Send KeyAction of oAddNew_bn
On_Key Key_Alt+Key_O Send KeyAction of oOk_bn
On_Key Key_Alt+Key_C Send KeyAction of oCancel_bn
On_Key Key_Alt+Key_S Send KeyAction of oSearch_bn
CD_End_Object // SalesP_sl
//====================================//
End Result of Code:
The code above results in a “drop-thru” of the new Sales Person entered and puts their ID/intials in the data entry view without stopping at the selection list.
By
Peter A Donovan
Applause Software
September, 2007
[1] The code from the Modal Dialog
[2] The code from the Selection List
(In VDF 12.1 code)
//====================================//
// dbModalPanel = Popup Dialog for entering new sales person
Use DFClient.pkg
Use SalesP.DD
Use Customer.DD
Use OrderHea.DD
Use DFEntry.pkg
Object SalepAddNewDialog is a dbModalPanel
Property Boolean pbOK
Property RowID priRowID
Object oSalesp_DD is a Salesp_DataDictionary
End_Object
Set Main_DD to oSalesp_DD
Set Server to oSalesp_DD
Set Label to "Add or Edit Sales Person"
Set Size to 83 308
Set Location to 2 2
Set Border_Style to Border_Dialog
Set Auto_Clear_DEO_State to False // no clear on save
Procedure Popup
Set pbOk to False
Send Clear of oSalesp_DD
Forward Send Popup
End_Procedure
Object oSalesP_ID is a dbForm
Entry_Item SalesP.ID
Set Location to 9 91
Set Size to 13 42
Set Label to "Sales Person ID:"
End_Object
Object oSalesP_Name is a dbForm
Entry_Item SalesP.Name
Set Location to 23 91
Set Size to 13 156
Set Label to "Sales Person Name:"
Set Label_Col_Offset to 2
Set Label_Justification_Mode to JMode_Right
End_Object
Object oOK_btn is a Button
Set Label to C_$OK
Set Location to 44 185
Set Default_State to True
Procedure OnClick
Handle hServer
RowID riRowID
Move oSalesp_DD to hServer
Send Request_Save
If (Should_Save(hServer)) Procedure_Return
If (not(Current_Record(hServer))) Begin
Send Info_Box "Please Find Or Enter A New Sales Person ~ Then Click Ok"
Procedure_Return
End
Get CurrentRowID of hServer to riRowID
Set priRowID to riRowID
Set pbOK to True
Send Close_Panel
End_Procedure
End_Object
Object oCancel_btn is a Button
Set Label to C_$Cancel
Set Location to 44 243
Procedure OnClick
Send Close_Panel
End_Procedure
End_Object
On_Key Key_Alt+Key_O Send KeyAction of oOk_btn
On_Key Key_Alt+Key_C Send KeyAction of oCancel_btn
End_Object
//====================================//
// Selection List augmented only for the add new button:
Use DFClient.pkg
Use DFSelLst.pkg
Use Windows.pkg
Use SalesP.DD
Use SalepAddNewDialog.dg
CD_Popup_Object SalesP_sl is a dbModalPanel
Set Minimize_Icon to False
Set Label to "Sales People List"
Set Size to 118 265
Set Location to 4 5
Set piMinSize to 97 174
Object SalesP_DD is a SalesP_DataDictionary
End_Object // Salesp_DD
Set Main_DD to SalesP_DD
Set Server to SalesP_DD
Object oSelList is a dbList
Set Main_File to SalesP.File_Number
Set Ordering to 1
Set Size to 71 248
Set Location to 6 6
Set peAnchors to anAll
Set pbHeaderTogglesDirection to True
Begin_Row
Entry_Item SalesP.ID
Entry_Item SalesP.Name
End_Row
Set Form_Width 0 to 40
Set Header_Label 0 to "ID"
Set Form_Width 1 to 200
Set Header_Label 1 to "Sales Person Name"
End_Object // oSelList
Object oOK_bn is a Button
Set Label to "&Ok"
Set Location to 81 97
Set peAnchors to anBottomRight
Set Default_State to True
Procedure OnClick
Send OK To oSelList
End_Procedure
End_Object // oOK_bn
Object oCancel_bn is a Button
Set Label to "&Cancel"
Set Location to 81 151
Set peAnchors to anBottomRight
Procedure OnClick
Send Cancel To oSelList
End_Procedure
End_Object // oCancel_bn
Object oSearch_bn is a Button
Set Label to "&Search..."
Set Location to 81 205
Set peAnchors to anBottomRight
Procedure OnClick
Send Search To oSelList
End_Procedure
End_Object // oSearch_bn
Object oAddNew_bn is a Button
Set Label to "&Add New"
Set Location to 81 8
Set peAnchors to anBottom
Procedure OnClick
Handle hModalDialog
Move (SalepAddNewDialog(Self)) to hModalDialog
Send Popup of hModalDialog
If (pbOk(hModalDialog)) Begin
Send FindByRowID of (Server(Self)) Salesp.File_Number (priRowID(hModalDialog))
Send Display of oSelList
Send Ok of oSelList
End
End_Procedure
End_Object
On_Key Key_Alt+Key_A Send KeyAction of oAddNew_bn
On_Key Key_Alt+Key_O Send KeyAction of oOk_bn
On_Key Key_Alt+Key_C Send KeyAction of oCancel_bn
On_Key Key_Alt+Key_S Send KeyAction of oSearch_bn
CD_End_Object // SalesP_sl
//====================================//
End Result of Code:
The code above results in a “drop-thru” of the new Sales Person entered and puts their ID/intials in the data entry view without stopping at the selection list.
By
Peter A Donovan
Applause Software
September, 2007
No comments:
Post a Comment