2 Listboxes browsing different parts of the same Database

2 Listboxes browsing different parts of the same Database

Postby Ollie » 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?

Code: Select all  Expand view
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)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Biel EA6DD » 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/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

Postby James Bott » Tue Jul 03, 2007 3: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.

Code: Select all  Expand view
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:

Code: Select all  Expand view
oDefects1:= TDefects():new()
oDefects2:= TDefects():new()


And then build the browses:

Code: Select all  Expand view
@ 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 52 guests