Article View: borland.public.vdbase.data.sql
Article #1620Re: 1 to many
From: Joe Yuzamas
Date: Sun, 09 Nov 1997 00:00
Date: Sun, 09 Nov 1997 00:00
101 lines
4426 bytes
4426 bytes
Donnie
Here is an example of a two combobox list that I use. This routine can
build both the list or just the last. On_Open builds both list. Also
required is an on_change event for each box. The on_change for the first
box rebuilds the second list based on the value of the first. The on_change
for the second, updates the screen based on the values of both or what ever
you want to happen. I tryed to comment it a little. Please excuse the extra
code as I just cut and pasted this from an app I am working on.
Joe
Procedure BLDPONRLST(nNoLst)
* Arrays have been instantated prior to this call with the commands
* form.oPrjLst = NEW ARRAY()
* form.oAmLst = NEW ARRAY()
* Var. nNoLst is used to control whether to build both list or just
* one. Disregard the code required for the Custom Security Class
* mentioned.
SELECT COUNT(FY) AS nCnt FROM PONR
IF nCNT > 0 && Check for no records
IF nNoLst > 1
form.oPrjLst.Resize(1) && Reset array size to one
form.oPrjLst[form.oPrjLst.Size] = '' && clear first
* The next line is for a Custom Security Class to control access
IF _app.oSec.LEVOK('FM-Approver','Funds-Approver')
SELECT DISTINCT * FROM PONR && Select one unique record from
the table
ELSE
cName = RTRIM(_app.oSec.USID) && Same as above, except
Qualify by
&& Div which is in table
AUTH
&& This restricts the users
access
&& to records.
SELECT OFSYM FROM AUTH WHERE ANAME = :cName
cDIV = OFSYM
SELECT DISTINCT * FROM PONR WHERE DIV = :cDiv
ENDIF
IF .NOT. EMPTY(FY) && Check again for empty table
form.oPrjLst[form.oPrjLst.Size] = FY+'-'+PONR && load first
record
&& into Array
SKIP
ENDIF
DO WHILE .NOT. EMPTY(FY) && Continue to Load Array
form.oPrjLst.Add(1) && until end of table
form.oPrjLst[form.oPrjLst.Size] = FY+'-'+PONR
SKIP
ENDDO
form.PRJLSTFLD.DataSource = 'ARRAY form.oPRJLST' && Set
combobox to array
form.PRJLSTFLD.Value = form.oPrjLst[1] && Display first
entry in combobox
ENDIF
IF nNoLst > 0
form.oAmLst.Resize(1)
form.oAmLst[form.oAmLst.Size] = ''
cPrjOrder = form.PRJLSTFLD.Value
SELECT * FROM AMEND WHERE PRJ_NO = :cPrjOrder
IF .NOT. EMPTY(AMEND_NO)
form.oAmLst[form.oAmLst.Size] = AMEND_NO
SKIP
ENDIF
DO WHILE .NOT. EMPTY(AMEND_NO)
form.oAmLst.Add(1)
form.oAmLst[form.oAmLst.Size] = AMEND_NO
SKIP
ENDDO
form.AMLSTFLD.DataSource = 'ARRAY form.oAmLST'
form.AMLSTFLD.Value = form.oAmLst[1]
ENDIF
Class::UPDSCR()
ELSE
MsgDlg('No Records Found!','No Records', 'OK',;
'Warn')
form.oPrjLst.Resize(1)
form.oPrjLst[form.oPrjLst.Size] = ''
form.PRJLSTFLD.DataSource = 'Array form.oPrjLst'
form.oAmLst.Resize(1)
form.oAmLst[form.oAmLst.Size] = ''
form.AMLSTFLD.DataSource = 'Array form.oAmLst'
ENDIF
donnie roberts <dbribs@flash.net> wrote in article
<346124A8.60BE@flash.net>...
> I have a dbf of class room #s and a dbf of students with class room #s
> as one of the fields. I want to have a combobox select a class room #
> from the class room dbf and point to the first student record in the
> student dbf for that class # selected.
>
> Thanks. Donnie
>
Technical Details
Message-ID:
<01bced25$3c027c60$1030f489@jyuzamas.robins.af.mil>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<346124A8.60BE@flash.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: ff5a1,b5eb5c2ed134c007 X-Google-Attributes: gidff5a1,public From: "Joe Yuzamas" <jyuzamas@wrdiss1.robins.af.mil> Subject: Re: 1 to many Date: 1997/11/09 Message-ID: <01bced25$3c027c60$1030f489@jyuzamas.robins.af.mil> X-Deja-AN: 288105381 References: <346124A8.60BE@flash.net> Organization: U.S. Air Force Newsgroups: borland.public.vdbase.data.sql