FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour 2 Listboxes browsing different parts of the same Database
Posts: 233
Joined: Sat Dec 30, 2006 06:10 AM

2 Listboxes browsing different parts of the same Database

Posted: Tue Jul 03, 2007 11:17 AM
I remember seeing a SAMPLE that used 2 listboxes to display different parts of the same database.

I can't find it. Can anyone tell me what its called?

Would one use oDATABASE objects for this?

Select DEFECTS
DATABASE oDBF_DEFECTS
oDBF_DEFECTS:GoTop()
oListBoxSection:SetoDbf( oDBF_DEFECTS )
oListBoxSection:cAlias = oDBF_DEFECTS:cAlias
   #xtranslate oDBF_DEFECTS:DEFECTS: => oDBF_DEFECTS:
   ADD COLUMN TO BROWSE oListBoxSection DATA oDBF_DEFECTS:DEFECTS:SECTION HEADER "Section" OEM ALIGN LEFT

DATABASE oDBF_DEFECTS2
oDBF_DEFECTS:GoTop()
oListBoxSection2:SetoDbf( oDBF_DEFECTS2 )
oListBoxSection2:cAlias = oDBF_DEFECTS2:cAlias
   #xtranslate oDBF_DEFECTS2:DEFECTS: => oDBF_DEFECTS2:
   ADD COLUMN TO BROWSE oListBoxSection2 DATA oDBF_DEFECTS2:DEFECTS:SECTION HEADER "Section" OEM ALIGN LEFT
Many thanks

Ollie.



Using:

xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)

Borland C++ 5.5.1

FWH 9.04 (2009 Apr)
Posts: 682
Joined: Tue Feb 14, 2006 09:48 AM

2 Listboxes browsing different parts of the same Database

Posted: Tue Jul 03, 2007 11:27 AM

To display diferent records from same dbf, you must open the DBF two times with dferent alias.

Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

2 Listboxes browsing different parts of the same Database

Posted: Tue Jul 03, 2007 03:34 PM
Ollie,

>To display diferent records from same dbf, you must open the DBF two times with dferent alias.

And with my TData class you don't have to deal with aliases. You would just create two database objects and use them. No dealing with SELECT statements either.

Best is to create a defects class.

class TDefects
   method new()
endclass

method new() class TDefects
      super:new(,"defects")
      ::use()
      if ::used()
         addIndex("defect1")
         addIndex("defect2")
         ::setOrder(1)
         ::gotop()
      endif
return self


OK, now you can just open two copies of the database:

oDefects1:= TDefects():new()
oDefects2:= TDefects():new()


And then build the browses:

@ 0,0 oLbx1 fields oDefects1:date, oDefects1:descrip;
      headers "Date","Description";
      alias oDefects1:cAlias
      
@0,0 oLbx2 fields oDefects2:date, oDefects2:descrip;
      headers "Date","Description";
      alias oDefects2:cAlias


Simple!

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion