I would think this exercise was fairly straight forward but has not turned out that way .. I have a table I want to read an Employee name into an array then use that array with the ITEMS clause to be able to chose my name in a ComboBox.
Unfortunately, when I create the array and use it like ITEMS aTech .. the computer GPFs and I do not know why .. Here is a portion of my code.
Please let me know what I am doing wrong ?
Thanks
Rick Lipkin
- Code: Select all Expand view
// create the Tech pull down array
cSql := "Select [First Name], [Last Name], [Service Calls], [Shop Repairs],[Employee Number] "
cSql += "From Employees Order by [First Name]"
oRsEmp := TOleAuto():New( "ADODB.Recordset" )
oRsEmp:CursorType := 1 // opendkeyset
oRsEmp:CursorLocation := 3 // local cache
oRsEmp:LockType := 3 // lockoportunistic
TRY
oRsEmp:Open( cSQL,xCONNECT )
CATCH oErr
MsgInfo( "Error in Opening EMPLOYEES table" )
* _CleanUP()
RETURN(.F.)
END TRY
aTech := {}
aLine := { "Blank" }
AAdd( aTech, aLine )
xBrowse( aTech )
If oRsEmp:eof
Else
oRsEmp:MoveFirst()
Do While .not. oRsEmp:eof
If oRsEmp:Fields("Shop Repairs"):Value = .t. .or.;
oRsEmp:Fields("Service Calls"):Value = .t.
Else
oRsEmp:MoveNext()
Loop
Endif
If empty( oRsEmp:Fields("First Name"):Value )
cFname := "Unknown"
Else
cFname := alltrim(oRsEmp:Fields("First Name"):Value)
Endif
If empty( oRsEmp:Fields("Last Name"):Value )
cLname := "Unknown"
Else
cLname := alltrim(oRsEmp:Fields("Last Name"):Value)
Endif
cName := cFname+" "+cLname
aLine := { cName }
AAdd( aTech, aLine )
oRsEmp:MoveNext()
End Do
Endif
oRsEmp:CLose()
xBrowse( atech ) // array is created corectly
...
...
cTech := space(50)
REDEFINE COMBOBOX oTech var cTech ID 127 of oWorkB ;
ITEMS aTech