3.6.2.6. Showing an Options List Using VBScript
This sample allows you to show the user a configurable option list of values in a modal dialogue to help in a value selection:
Example I:
' Prepare options dialog
Call ChronoApp.dlg_seloption_prepare("Select Option dialog","Select a value from different options")
' Add Options columns
Call ChronoApp.dlg_seloption_add_column("NAME","sz:150")
Call ChronoApp.dlg_seloption_add_column("VALUE","sz:80|align:Right")
' Set Row items text
idx = ChronoApp.dlg_seloption_add_row("Option 1")
Call ChronoApp.dlg_seloption_setrowtext(idx, 1, "NAME 1")
Call ChronoApp.dlg_seloption_setrowtext(idx, 2, "VALUE 1")
idx = ChronoApp.dlg_seloption_add_row("Option 2")
Call ChronoApp.dlg_seloption_setrowtext(idx, 1, "NAME 2")
Call ChronoApp.dlg_seloption_setrowtext(idx, 2, "VALUE 2")
' Show Options dialog
sel = ChronoApp.dlg_seloption_show()
' If a record is Selected rowdata is retrieved, in this Case is the record position On the recordset
If Not sel = "" Then
ChronoApp.MsgBox "Test dialog", "Option selected: " & sel, 0,0
End If
Example II:
' More than One result, show Options dialog
Call ChronoApp.dlg_seloption_prepare("Select option dialog","Select a value from different options")
' Add Options columns
Call ChronoApp.dlg_seloption_add_column("ADH_NIR","sz:150")
Call ChronoApp.dlg_seloption_add_column("ADH_SIREN","sz:80|align:Right")
Call ChronoApp.dlg_seloption_add_column("ADH_ID_ACR","sz:80|align:Left")
Call ChronoApp.dlg_seloption_add_column("ADH_SITUATION","sz:80|align:Center")
Call ChronoApp.dlg_seloption_add_column("ADH_NOM_PAT","")
' Add Options values
recordid = 0
Do While Not resUsers60.EOF
' Add Row Setting recordid as rowdata
idx = ChronoApp.dlg_seloption_add_row(recordid)
' Set Row items text
If Not IsNull(resUsers60.Fields("ADH_NIR")) Then Call ChronoApp.dlg_seloption_setrowtext(idx, 1, resUsers60.Fields("ADH_NIR"))
If Not IsNull(resUsers60.Fields("ADH_SIREN")) Then Call ChronoApp.dlg_seloption_setrowtext(idx, 2, resUsers60.Fields("ADH_SIREN"))
If Not IsNull(resUsers60.Fields("ADH_ID_ACR")) Then Call ChronoApp.dlg_seloption_setrowtext(idx, 3, resUsers60.Fields("ADH_ID_ACR"))
If Not IsNull(resUsers60.Fields("ADH_SITUATION")) Then Call ChronoApp.dlg_seloption_setrowtext(idx, 4, resUsers60.Fields("ADH_SITUATION"))
If Not IsNull(resUsers60.Fields("ADH_NOM_PAT")) Then Call ChronoApp.dlg_seloption_setrowtext(idx, 5, resUsers60.Fields("ADH_NOM_PAT"))
recordid = recordid + 1
resUsers60.MoveNext
Loop
' Show Options dialog
recordsel = ChronoApp.dlg_seloption_show()
' If a record is Selected rowdata is retrieved, in this Case is the record position On the recordset
If Not recordsel = "" Then
recordsel = Int(recordsel) ' To allow Int comparation
recordid = 0
resUsers60.MoveFirst
Do While Not resUsers60.EOF
If recordid = recordsel Then ' This is the Selected record
FillRecordData(resUsers60)
UserField_NIR.ValidateStatus = 1
Exit Sub
End If
recordid = recordid + 1
resUsers60.MoveNext
Loop
End If