This is a bit much, but here it is.
It is ugly - I've been grasping at straws, changing and all sorts of stuff to try and find an answer.
**************************************************
**** Text1.GotFocus
this.value = ''
THISform.grdSuperCombo.RECORDSOURCE = ""
THISform.grdSuperCombo.REFRESH()
done=setRelations()
select chart
set order to chart
THIS.PARENT.imgScanner.VISIBLE = .F.
THIS.PARENT.lblScannerReady.CAPTION = "Scanner Not Ready"
glChangeValue = .F.
THISFORM.pgfMain.pagCharts.pgfCharts.pagChartLookup.cntAddChart.VISIBLE = .F.
THISFORM.REFRESH
WITH THIS
SELECT chart
SET ORDER TO 2
ENDWITH
THISFORM.cmdSuperCombo.VISIBLE = .F.
THISFORM.grdSuperCombo.RECORDSOURCE = ""
THISFORM.grdSuperCombo.REFRESH
*** modified call to supercombo with additional parameters
WITH THISFORM
.cusSuperCombo1.mCallGrid( ;
"pgfMain.pagCharts.pgfCharts.pagChartLookup.Text1", ;
[chart.c_chart_id], ;
[chart] ,2 ,[c_chart_id] ,1 ,15 ,164 ,160 )
* lookup object ,
* table.lookup field,
* index name ,xtra width,disp field ,#columns ,HorPos ,VerPos ,Height)
ENDWITH
THISFORM.shpGridLocater.LEFT = 13
THISFORM.shpGridLocater.TOP = 234
THISFORM.shpGridLocater.WIDTH = 102
THISFORM.shpGridLocater.VISIBLE = .T.
THISFORM.grdSuperCombo.REFRESH
THISFORM.REFRESH
**************************************************
**** Text1.InteractiveChange
glChangeValue = .T.
WITH THISFORM
IF .grdSuperCombo.LEFT # 1000
.cusSuperCombo1.mFindData(THIS.VALUE)
gnRecno = .cusSuperCombo1.nrecno
GOTO gnRecno
ENDI
ENDW
lnLen = LEN(ALLTRIM(THIS.VALUE))
IF UPPER(ALLTRIM(THIS.VALUE)) # LEFT(UPPER(ALLTRIM(chart.c_chart_id)),lnLen)
THISFORM.grdSuperCombo.FORECOLOR = RGB(255,0,0)
ELSE
THISFORM.grdSuperCombo.FORECOLOR = RGB(0,0,0)
ENDIF
IF UPPER(ALLTRIM(THIS.VALUE)) # LEFT(UPPER(ALLTRIM(THISFORM.grdSuperCombo.column1.text1.VALUE)),lnLen)
THISFORM.grdSuperCombo.column1.text1.FORECOLOR = RGB(0,150,0)
THISFORM.grdSuperCombo.REFRESH
ENDIF
THISFORM.grdSuperCombo.REFRESH
THISFORM.REFRESH
**************************************************
************Text1.KeyPress
LPARAMETERS nKeyCode, nShiftAltCtrl
WITH THIS
DO CASE
CASE nKeyCode = 9
DODEFAULT()
CASE nKeyCode = 13
goto gnRecno
dodefault()
thisform.refresh
ENDC
ENDW
THISFORM.REFRESH
**************************************************
***** Text1.LostFocus
select chart
WITH THISFORM
DO CASE
CASE LASTKEY() = 9 ;
OR LASTKEY() = 13 ;
OR LASTKEY() = 15
THISFORM.grdSuperCombo.VISIBLE = .F.
THISFORM.shpGridLocater.VISIBLE = .F.
=committransaction()
lcChart = CodeChartId(n_client_id,n_vol_id)
SELECT chart
SET ORDER TO chart
SEEK lcChart
gcChart = ALLTRIM(STR(n_client_id,7,0)+ '-' + ALLTRIM(STR(n_vol_id,2,0)))
gcFacilityAt = facility.c_facility_name
gcProgramAt = facility.c_program_name
glChartConfidential = client.l_confidential
glLstChartFlag = .T.
THISFORM.grdSuperCombo.RECORDSOURCE = ""
THISFORM.grdSuperCombo.REFRESH
THISFORM.displayvalues
THISFORM.showchart
THIS.PARENT.txtScannedChart.SETFOCUS
THISFORM.REFRESH
=committransaction()
DODEFAULT()
IF THIS.NAME # THISFORM.cusSuperCombo1.cTextBoxName
.cmdSuperCombo.LEFT = 1000
.grdSuperCombo.LEFT = 1000
ENDI
OTHERWISE
THISFORM.grdSuperCombo.SETFOCUS
ENDC
ENDW
gnClient = n_client_id
THISFORM.pgfMain.pagCharts.pgfCharts.pagChartTransfer.ENABLED = .T.
THISFORM.pgfMain.pagCharts.pgfCharts.pagChartAudit.ENABLED = .T.
THISFORM.pgfMain.pagCharts.pgfCharts.pagCorrespondance.ENABLED = .T.
THISFORM.REFRESH
**************************************************
******* txtClientName.Click
this.value = ''
This.refresh
**************************************************
************txtClientName.GotFocus
THISFORM.grdSuperCombo.RECORDSOURCE = ""
THISFORM.grdSuperCombo.REFRESH()
THIS.VALUE = ''
THIS.REFRESH
THIS.PARENT.imgScanner.VISIBLE = .F.
THIS.PARENT.lblScannerReady.CAPTION = "Scanner Not Ready"
glChangeValue = .F.
THISFORM.pgfMain.pagCharts.pgfCharts.pagChartLookup.cntAddChart.VISIBLE = .F.
THISFORM.REFRESH
SELECT client
SET ORDER TO 3
THISFORM.cmdSuperCombo.VISIBLE = .F.
WITH THISFORM
.cusSuperCombo1.mCallGrid( ;
"pgfMain.pagCharts.pgfCharts.pagChartLookup.txtClientName", ;
[client.c_name_lookup], ;
[namelookup] ,2 ,[c_name_lookup] ,1 ,540 ,370 ,120)
* lookup object ,
* table.lookup field,
* index name ,xtra width,disp field ,#columns ,HorPos ,VerPos ,Height)
ENDWITH
THISFORM.shpGridLocater.LEFT = 538
THISFORM.shpGridLocater.TOP = 422
THISFORM.shpGridLocater.WIDTH = 222
THISFORM.shpGridLocater.VISIBLE = .T.
THISFORM.grdSuperCombo.REFRESH
THISFORM.REFRESH
**************************************************
************txtClientName.GotFocus
THISFORM.grdSuperCombo.RECORDSOURCE = ""
THISFORM.grdSuperCombo.REFRESH()
THIS.VALUE = ''
THIS.REFRESH
THIS.PARENT.imgScanner.VISIBLE = .F.
THIS.PARENT.lblScannerReady.CAPTION = "Scanner Not Ready"
glChangeValue = .F.
THISFORM.pgfMain.pagCharts.pgfCharts.pagChartLookup.cntAddChart.VISIBLE = .F.
THISFORM.REFRESH
SELECT client
SET ORDER TO 3
THISFORM.cmdSuperCombo.VISIBLE = .F.
WITH THISFORM
.cusSuperCombo1.mCallGrid( ;
"pgfMain.pagCharts.pgfCharts.pagChartLookup.txtClientName", ;
[client.c_name_lookup], ;
[namelookup] ,2 ,[c_name_lookup] ,1 ,540 ,370 ,120)
* lookup object ,
* table.lookup field,
* index name ,xtra width,disp field ,#columns ,HorPos ,VerPos ,Height)
ENDWITH
THISFORM.shpGridLocater.LEFT = 538
THISFORM.shpGridLocater.TOP = 422
THISFORM.shpGridLocater.WIDTH = 222
THISFORM.shpGridLocater.VISIBLE = .T.
THISFORM.grdSuperCombo.REFRESH
THISFORM.REFRESH
**************************************************
************txtClientName.KeyPress
LPARAMETERS nKeyCode, nShiftAltCtrl
WITH THIS
DO CASE
CASE nKeyCode = 9
DODEFAULT()
CASE nKeyCode = 13
select chart
goto gnRecno
SET ORDER TO chart
dodefault()
THISFORM.grdSuperCombo.REFRESH
thisform.refresh
ENDC
ENDW
THISFORM.REFRESH
**************************************************
***********txtClientName.LostFocus
WITH THISFORM
DO CASE
CASE LASTKEY() = 9 ;
OR LASTKEY() = 13 ;
OR LASTKEY() = 15
THISFORM.grdSuperCombo.VISIBLE = .F.
THISFORM.shpGridLocater.VISIBLE = .F.
=committransaction()
select client
goto gnRecno
SET ORDER TO 1
gnClient = n_client_id
SELECT chart
SET ORDER TO 3
SEEK gnClient
SET ORDER TO chart
gcChart = ALLTRIM(STR(n_client_id,7,0)+ '-' + ALLTRIM(STR(n_vol_id,2,0)))
gcFacilityAt = facility.c_facility_name
gcProgramAt = facility.c_program_name
glChartConfidential = client.l_confidential
glLstChartFlag = .T.
THISFORM.grdSuperCombo.RECORDSOURCE = ""
THISFORM.grdSuperCombo.REFRESH
=setRelations()
THISFORM.REFRESH
THISFORM.displayvalues
THISFORM.showchart
THIS.PARENT.txtScannedChart.SETFOCUS
=committransaction()
DODEFAULT()
IF THIS.NAME # THISFORM.cusSuperCombo1.cTextBoxName
.cmdSuperCombo.LEFT = 1000
.grdSuperCombo.LEFT = 1000
ENDI
OTHERWISE
THISFORM.grdSuperCombo.SETFOCUS
ENDC
ENDW
gnClient = n_client_id
THISFORM.pgfMain.pagCharts.pgfCharts.pagChartTransfer.ENABLED = .T.
THISFORM.pgfMain.pagCharts.pgfCharts.pagChartAudit.ENABLED = .T.
THISFORM.pgfMain.pagCharts.pgfCharts.pagCorrespondance.ENABLED = .T.
*This.value = ''
THISFORM.REFRESH
**************************************************
***** cussupercombo.mcallgrid
LPARAMETERS TextBoxName ,;
LookupTableField ,;
LookupTableIndex ,;
ExtraWidth ,;
DisplayField ,;
ColumnsCount ,;
lnHorPos ,;
lnVerPos ,;
lnHeight
IF !EMPTY(TextBoxName) AND !EMPTY(LookupTableField)
WITH THIS
.cTextBoxName = TextBoxName && Name of textbox
.cLookupTableField = LookupTableField && Table.field
.cLookupField = SUBS(.cLookupTableField ,; && field
AT([.],.cLookupTableField) + 1 ,;
LEN(.cLookupTableField))
.cLookupTable = SUBS(.cLookupTableField ,; && Table
1,AT([.],.cLookupTableField) - 1)
IF !EMPTY(LookupTableIndex)
.cLookupTableIndex = LookupTableIndex && Index
ELSE
.cLookupTableIndex = []
ENDI
SET ORDER TO .cLookupTableIndex IN .cLookupTable && changed from .clookupfield
IF !EMPTY(ExtraWidth) && Extra pixels on width
.nExtraWidth = ExtraWidth
ELSE
.nExtraWidth = 0
ENDI
IF !EMPTY(DisplayField)
.cDisplayField = DisplayField
ELSE
.cDisplayField = []
ENDI
.nRecno = RECNO(.cLookupTable)
lcLeft = STR(lnHorPos,4,0)
lcTop = STR(lnVerPos,4,0)
lcHeight = STR(lnHeight,4,0)
lcWidth = [THISFORM.] ;
+ .cTextBoxName ;
+ [.Width + 16]
IF !EMPTY(ExtraWidth)
lcWidth = [THISFORM.] ;
+ .cTextBoxName ;
+ [.Width + 16 + THIS.nExtraWidth]
ENDI
* Setup grid
DO CASE
CASE ColumnsCount = 1
WITH THISFORM.grdSuperCombo
.LEFT = EVAL(lcLeft)
.TOP = EVAL(lcTop)
.WIDTH = EVAL(lcWidth)
.HEIGHT = EVAL(lcHeight)
.Column1.WIDTH = EVAL(lcWidth)
.RECORDSOURCE = THIS.cLookupTable
IF !EMPTY(THIS.cDisplayField)
.Column1.CONTROLSOURCE = THIS.cDisplayField
ELSE
.Column1.CONTROLSOURCE = THIS.cLookupTableField
ENDI
.VISIBLE = .T.
ENDW
ENDC
ENDW
ENDI
**************************************************
***** cussupercombo.mfinddata
LPARAMETERS TextBoxValue
WITH THIS
lcAlias = ALIAS()
lcOrder = ORDER()
*
SELE (.cLookupTable) && Select lookup table
IF EMPTY(.cLookupTableIndex)
SET ORDER TO TAG (.cLookupField) && Select table order
ELSE
SET ORDER TO TAG (.cLookupTableIndex) && Select table order
ENDI
*
lcField = .cLookupTableField && Check out field type
*
DO CASE
CASE VARTYPE(&lcField) = [D]
SEEK DTOS(TextBoxValue)
CASE VARTYPE(&lcField) = [C]
SET NEAR ON
SEEK UPPE(ALLT(TextBoxValue))
SET NEAR OFF
ENDC
*
.nRecNo = RECN(.cLookupTable)
THISFORM.grdSuperCombo.REFRESH()
*
IF !EMPTY(lcAlias) && Select original table and order
SELE (lcAlias)
ENDI
*
IF !EMPTY(lcOrder)
SET ORDER TO TAG (lcOrder)
ENDI
ENDW
**************************************************
***** Set Relations - set up all relations needed for main routines
FUNCTION SetRelations()
select category
set order to category
………… other relations deleted for brevity
select chart
set order to chart
set relation to n_client_id into client
set relation to c_status into status additive
set relation to c_indiv_at into contact_master_file additive
set relation to c_facility_at into facility additive
set relation to c_chart_id into correspondance_log additive
set relation to c_chart_id into transactions additive
set relation to c_chart_id into audits additive
return
ENDFUNC && SetRelations