Hello,
I'm converting a dialog with 2 listbox to xbrowse
The two browses are browsing a recordset.
When the first one is change, I update the second recordset (not a filter, but running a new guery) and do a refresh()
With the listbox this is working fine, but with xbrowse it doesn't work.
If the second browse is showing only one record after calling the dialog, if keeps on displaying only one record, even when I change the first one.
The data of the first line is updated, but not the number of fields
I already tried to so a setado(oRs) again with the new recordset, but that doesn't work.
xbrowse refresh with new recordset
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
xbrowse refresh with new recordset
Regards,
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Re: xbrowse refresh with new recordset
Marc
I think I understand what you are doing .. and what is interesting about xBrowse .. is that you can oRs2:Close() the recordset ( without destroying oLbx2 ) and then re-open\create the oRs2 recordset again with a new query which will probably capture your new records .. as long as the same query and fields are used and re-associated with the same oLbx2 xBrowse .. here is the pseudo code :
Create recordset oRs1 for the first xBrowse oLbx1
Create recordset oRs2... "Select Field1,Field2,Field3 where <some condition>" that ties back to the first recordset and xBrowse oLbx2
xbrowse 1 .. creates a new record
oRs2:CLose()
Re-create the same oRs2 recordset but now sql picks up the new record in your query
oRs2.... "Select Field1,Field2,Field3 where <some condition>" that ties back to the first recordset
oLbx2:ReFresh() .. using the same oRs2 value ..
What this code attempts to do is like a oRs2:ReQuery() , but you are actually closing the second recordset oRs2 and then re-creating the same recordset oRs2 which should return the results of the new row created in your first browse..
So why not just use oRs2:ReQuery() then oLbx2:ReFresh() .... sometimes that works and other times it does not based on how quickly the Sql Database can cache its new rows. When you issue a new query using the same oRs2 conditions .. generally the database will return the new appended row based on the parameters of the conditions of the first listbox.
Hope that made sense and I understood your question.
Rick Lipkin
I think I understand what you are doing .. and what is interesting about xBrowse .. is that you can oRs2:Close() the recordset ( without destroying oLbx2 ) and then re-open\create the oRs2 recordset again with a new query which will probably capture your new records .. as long as the same query and fields are used and re-associated with the same oLbx2 xBrowse .. here is the pseudo code :
Create recordset oRs1 for the first xBrowse oLbx1
Create recordset oRs2... "Select Field1,Field2,Field3 where <some condition>" that ties back to the first recordset and xBrowse oLbx2
xbrowse 1 .. creates a new record
oRs2:CLose()
Re-create the same oRs2 recordset but now sql picks up the new record in your query
oRs2.... "Select Field1,Field2,Field3 where <some condition>" that ties back to the first recordset
oLbx2:ReFresh() .. using the same oRs2 value ..
What this code attempts to do is like a oRs2:ReQuery() , but you are actually closing the second recordset oRs2 and then re-creating the same recordset oRs2 which should return the results of the new row created in your first browse..
So why not just use oRs2:ReQuery() then oLbx2:ReFresh() .... sometimes that works and other times it does not based on how quickly the Sql Database can cache its new rows. When you issue a new query using the same oRs2 conditions .. generally the database will return the new appended row based on the parameters of the conditions of the first listbox.
Hope that made sense and I understood your question.
Rick Lipkin
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: xbrowse refresh with new recordset
Is this master-child browse?
oBrw2:oRs:Close()
oBrw2:oRs := FW_OpenRecordSet( <NewQuery> )
oBrw2:GoTop()
oBrw2:Refresh()
Note: You can also consider Data Shaping for master-child browses
oBrw2:oRs:Close()
oBrw2:oRs := FW_OpenRecordSet( <NewQuery> )
oBrw2:GoTop()
oBrw2:Refresh()
Note: You can also consider Data Shaping for master-child browses
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
Re: xbrowse refresh with new recordset
Thank you Rao,
Now it's working.
My recordset is called 'oRSBlocks'
So I had to do:
Rick,
I can't do a requery(), because it's another query, but with the same returned fieldnames.
When I first did a oRs2:close(), before reading the new query, I had an error.
So I did
without closing it, but with bad result
Now it's working.
My recordset is called 'oRSBlocks'
So I had to do:
Code: Select all
oBrw2:oRs:close()
oRSBlocks := haalC300CMBlocks(vCM) //Function that return new recordset
oBrw2:oRs := oRSBlocks
oBrw2:gotop()
oBrw2:refresh()
I can't do a requery(), because it's another query, but with the same returned fieldnames.
When I first did a oRs2:close(), before reading the new query, I had an error.
So I did
Code: Select all
oRs2 = haalC300CMBlocks(vCM) //Function that return new recordset
oBrw2:Refresh()
Regards,
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: xbrowse refresh with new recordset
The problem was not with closing or not closing.
You assigned new recordset object to oRs2
But oBrw:oRs was still pointing to the old recordset.
In my suggestion, you are now assigning the new recordset to oBrw:oRs. This makes it work.
You assigned new recordset object to oRs2
But oBrw:oRs was still pointing to the old recordset.
In my suggestion, you are now assigning the new recordset to oBrw:oRs. This makes it work.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
xbrowse not refresh with bEditBlock
Hello, i have a problem
The idea is to type the code by hand or from a listbox, and update the description column
for this use the codeblock Helppre()
-----------
oLbxp:aCols[ 5 ]:nEditType := EDIT_GET_BUTTON //
// oLbxp:aCols[ 5 ]:bEditBlock := {||HelpcPres(oLbxp)}
oLbxp:aCols[ 5 ]:bEditBlock := {||(if(Helppre(),VolHpre(.t.),VolHpre(.f.)),.t.)}
---------------------------
Pressing the button displays the browse to select code, return it and put the description column 7
if I put this code in the VOLPRE functions, not updated anything
If lVol
oLbxp:aCols[ 5 ]:Value := cpres->pr_codi
oLbxp:aCols[ 7 ]:Value := cpres->pr_desc
Else
if I put this other code (I have seen it is not advisable to use it) but updated code and description of the two lines
If lVol
oLbxp:aCols[ 5 ]:bStrData := cpres->pr_codi
oLbxp:aCols[ 7 ]:bStrData := cpres->pr_desc
Else
the code for Helppre(), thir work fine in other cases
The idea is to type the code by hand or from a listbox, and update the description column
for this use the codeblock Helppre()
-----------
oLbxp:aCols[ 5 ]:nEditType := EDIT_GET_BUTTON //
// oLbxp:aCols[ 5 ]:bEditBlock := {||HelpcPres(oLbxp)}
oLbxp:aCols[ 5 ]:bEditBlock := {||(if(Helppre(),VolHpre(.t.),VolHpre(.f.)),.t.)}
---------------------------
Pressing the button displays the browse to select code, return it and put the description column 7
if I put this code in the VOLPRE functions, not updated anything
If lVol
oLbxp:aCols[ 5 ]:Value := cpres->pr_codi
oLbxp:aCols[ 7 ]:Value := cpres->pr_desc
Else
if I put this other code (I have seen it is not advisable to use it) but updated code and description of the two lines
If lVol
oLbxp:aCols[ 5 ]:bStrData := cpres->pr_codi
oLbxp:aCols[ 7 ]:bStrData := cpres->pr_desc
Else
Code: Select all
Static Function Lineas()
local codpre :=" "
XbrNumFormat( "E", .t. )
DbSelectArea("pliva")
pliva->(DBGOTOP())
DbSelectArea("bliva")
bliva->(ORDSETFOCUS("obra"))
DEFINE DIALOG oDDAbmLins OF oWndIva RESOURCE "IVA_LINS"
REDEFINE XBROWSE oLbx ID 110 OF oDDAbmlins;
HEADERS "N.Obra","Asiento","Fecha","Cuenta","Cpto.","Descripcion","Base","Tipo";
COLUMNS "Obra", "Asiento", "fecha","Cuenta","Concepto","Descrip","Base","tipo" ;
SIZES 50,50,65,55,30,210,90,33;
ALIAS ("bliva");
ON CHANGE (Toma_Lin(),PonerScope("bliva","Pliva",oLbxp))
olBx:lHScroll:=.F. //windows style en el recurso = 0x50210000 en .f. no funciona
REDEFINE XBROWSE oLbxp ID 120 OF oDDAbmlinp;
HEADERS "N.Obra","Asiento","Fecha","Cuenta","Prespto.","Natu","Descripcion","Importe";
COLUMNS "PL_OBRA", "PL_NUMASI", "PL_FECHA","PL_CUENTA","PL_PRES","PL_NATU","PL_DESC","PL_IMPORT" ;
SIZES 50,50,60,55,40,30,210,85;
AUTOSORT AUTOCOLS FASTEDIT LINES CELL FOOTERS;
ALIAS "pliva";
ON CHANGE (oLbxp:MakeTotals(), oLbxp:refresh ())
oLbxp:aCols[ 5 ]:nEditType := EDIT_GET_BUTTON
// oLbxp:aCols[ 5 ]:bEditBlock := {||HelpcPres(oLbxp)}
oLbxp:aCols[ 5 ]:bEditBlock := {||(if(Helppre(),VolHpre(.t.),VolHpre(.f.)),.t.)}
oLbxp:aCols[ 8 ]:nEditType := EDIT_GET
oLbxp:aCols[ 8 ]:nFooterType := AGGR_TOTAL
ACTIVATE DIALOG oDDAbmLins NOWAIT;
ON INIT ( oLbx:SetFocus(),PonerScope("bliva","pliva",oLbxp) )
DbSelectArea("bliva")
return nil
//----------------------------------------------------------------------
Static Function VolHpre(lVol)
If lVol
oLbxp:aCols[ 5 ]:Value := cpres->pr_codi
oLbxp:aCols[ 7 ]:Value := cpres->pr_desc
Else
oLbxp:gotocol( 5 )
EndIf
oLbxp:gotocol( 8 )
DbSelectArea("pliva")
return nil
the code for Helppre(), thir work fine in other cases
Code: Select all
#Include "FiveWin.ch"
Static lSel,oDlg, oLbxhpPre
FUNCTION HelpPre()
DbSelectArea("cPres")
lSel:=.F.
SetKey_Hlp()
DEFINE DIALOG oDlg RESOURCE "HLP1" TITLE "Ayuda Conceptos Presupuestarios"
REDEFINE XBROWSE oLbxhpPre ID 110 OF oDlg;
HEADERS "Codigo","Naturaleza","Descripcion";
COLUMNS "pr_codi", "pr_natu", "pr_desc";
SIZES 50,50,210;
AUTOSORT FOOTERS LINES CELL ;
ON LEFT DBLCLICK (lSel:=.T.,oDlg:End());
ALIAS "cPres";
ACTIVATE DIALOG oDlg CENTERED;
ON INIT olbxhpPre:SetFocus();
VALID (DelKey_Hlp(),.t.)
RETURN lSel
//------------------------------------//
Static Function SetKey_Hlp()
SET KEY VK_RETURN TO Hlp_Ok()
Return nil
Static Function Hlp_OK()
lSel:=.t.
oDlg:End()
Return nil
Static Function DelKey_Hlp()
SET KEY VK_RETURN TO
Return nil
Un saludo
___________________________________________________
La mente es como un paracaídas, solo funciona si se abre
Harbour 3.2.0dev (r1601050904) , Fivewin 16.04
___________________________________________________
La mente es como un paracaídas, solo funciona si se abre
Harbour 3.2.0dev (r1601050904) , Fivewin 16.04
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: xbrowse refresh with new recordset
bStrData expects a codeblock, try this:
oLbxp:aCols[ 5 ]:bStrData := { || cpres->pr_codi }
oLbxp:aCols[ 7 ]:bStrData := { || cpres->pr_desc }
oLbxp:aCols[ 5 ]:bStrData := { || cpres->pr_codi }
oLbxp:aCols[ 7 ]:bStrData := { || cpres->pr_desc }
Re: xbrowse refresh with new recordset
Ok, gracias Antonio, funciona
Un saludo
___________________________________________________
La mente es como un paracaídas, solo funciona si se abre
Harbour 3.2.0dev (r1601050904) , Fivewin 16.04
___________________________________________________
La mente es como un paracaídas, solo funciona si se abre
Harbour 3.2.0dev (r1601050904) , Fivewin 16.04