Hello,
Can someone tell me how to refresh the data in a listbox after the listbox has already been displayed. I have a background process updating a table and I am calling a function that uses the SELECT statement to pull the data, I get the correct recordcount however I cannot get the listbox to refresh with the updated data.
Here is my listbox code and function being to refresh data:
// Listbox...
@110,000 LISTBOX oLbx FIELDS ;
oSql:Fields( "MRNO" ):Value , ;
oSql:Fields( "CUSTID" ):Value , ;
UPPER( oSql:Fields( "PO" ):Value ) , ;
oSql:Fields( "RECV" ):Value , ;
oSql:Fields( "PKG_RCV" ):Value , ;
oSql:Fields( "CHECK_BY" ):Value , ;
oSql:Fields( "MRSERIAL" ):Value , ;
IF( oSql:Fields( "RFIDCOMPLETE" ):Value=1, "Yes", "No") , ;
oSql:Fields( "RFIDCOMMISSIONED" ):Value ;
HEADERS "M/R No.", "Cust ID", "P.O. No.", "Received", "Qty", "Received By", "Internal", "M/R Complete", "RFID Commissioned" ;
SIZES 100 , 100 , 100 , 100 , 85 , 100 , 125 , 100 , 200 ;
FONT oFont2 ;
OF oWnd SIZE nLbxW, nLbxH PIXEL
oLbx:bLogicLen = { || oSql:RecordCount }
oLbx:bGoTop = { || oSql:MoveFirst() }
oLbx:bGoBottom = { || oSql:MoveLast() }
oLbx:bSkip = { | nSkip | Skipper( oSql, nSkip ) }
oLbx:cAlias = "ARRAY1"
// Refresh routine...
//----------------------------------------------------------------------------//
static function SeekRfid( cSearch, cSearchK, oLbx )
local cSeek := ALLTRIM( cSearchK ) , ;
lSearch := .F. , ;
lFnd := .F.
IF lActive
RETURN (.T.)
ENDIF
lActive := .T.
TRY
oSql:=TOleAuto():New("ADODB.Recordset")
CATCH
MsgWait("It seems that your PC does not have MDAC installed OR MDAC is corrupted.")
RETURN (.F.)
END
// Set...
oSql:CursorType := 1 // opendkeyset
oSql:CursorLocation := 3 // local cache
oSql:LockType := 3 // lock opportunistic
// Set SQL string...
cSql := "SELECT * FROM mr"
TRY
oSql:Open( cSql, 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xDATABASE+';User Id='+xUSERID+';Password='+xPASSWORD )
CATCH oError
MsgWait("Failed to Connect to the Database")
RETURN .F.
END
MsgWait( LTRIM(STR(oSql:RecordCount,9)) )
oLbx:Disable()
Sysrefresh()
oLbx:Enable()
Sysrefresh()
//oLbx:MoveFirst()
oLbx:Refresh()
Sysrefresh()
lActive := .F.
RETURN (.T.)