Picklist

Post Reply
Colin Haig
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Picklist

Post by Colin Haig »

Hi All

I use the following as general picklist function

cIntls := BrowseaDBF(oEmp,{"INTLS","NAME"},{"Init","Name"},cFile,{||oEmp:intls},"",cIntls)


function BrowseaDBF(oData,aFields,aHdgs,cTitle,bReturnExp,xRetVal,cSoft)
local oDlg,oLbx,cLine := "",i := 0,nKey := 0,lExit := FALSE,nLen := 0

oData:GoTop()
oData:Seek(cSoft,TRUE)

for i := 1 to len( aFields )
cLine += "cValToChar("+aFields[i] + if( i < len( aFields ), "),", ")" )
SysRefresh()
next
nLen := len(cLine)

DEFINE DIALOG oDlg ;
FROM 2,5 TO 16,(42 + int((nLen/4))) ;
TITLE cTitle ;
STYLE nOr(4,WS_POPUP,WS_CAPTION,WS_THICKFRAME) ;

@0,0 LISTBOX oLbx FIELDS "" ;
SIZE 65 + (nLen * 2),65 + nLen ;
of oDlg ;
ON DBLCLICK (xRetVal := eval( bReturnExp ),lExit := TRUE, oDlg:End())


oLbx:nClrForeFocus := CLR_WHITE
oLbx:nClrBackFocus := CLR_BLUE
oLbx:nClrBackHead := CHEADBACK
oLbx:nClrForehead := CHEADFRONT

oLbx:bKeyChar := {|nKey| iif(nKey == VK_RETURN,(xRetVal := eval( bReturnExp),lExit := TRUE,oDlg:End()),)}


oLbx:aHeaders := aHdgs
oLbx:bLine := &("{|| {"+ cLine + "} }")

ACTIVATE DIALOG oDlg CENTERED ;
ON INIT(oDlg:SetControl(oLbx));
VALID(lExit)

return(xRetVal)

I was previously using another database server but now I have converted to the fivewin database class
and now I get an error on - oLbx:bLine := &("{|| {"+ cLine + "} }")


Error description: Error BASE/1003 Variable does not exist: INTLS
Args:

Stack Calls
===========
Called from: Fnctn.prg => (b)BROWSEADBF(165)
Called from: .\source\classes\WBROWSE.PRG => TWBROWSE:DEFAULT(1344)

Cheers

Colin
User avatar
James Bott
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Picklist

Post by James Bott »

Colin,

Error description: Error BASE/1003 Variable does not exist: INTLS

I am guessing the INTLS is a fieldname and you have not defined oLbx:cAlias.

Try adding:

oLbx:cAlias:= oData:cAlias

Regards,
James
Colin Haig
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: Picklist

Post by Colin Haig »

Hi James

You are right INTLS is a field name - I added what you said but
I still get the error - could it be that when you do the following

MsgInfo(alias()) it returns in this instance TDF05 and not the true
alias which is emplye.

The database is called 'emplye' and the two fields I pass in afields are 'intls' and 'name'

Thanks

Colin
User avatar
James Bott
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Picklist

Post by James Bott »

Colin,

MsgInfo(alias()) it returns in this instance TDF05 and not the true
alias which is emplye.


MsgInfo( alias() ) is returning the alias of the current workarea which may or may not be the workarea of the database object.

oData:cAlias IS the workarea of the database object. TDatabase will not generate an alias name like "emplye" so I don't know where you got that. What do you get when you do msgInfo( oData:cAlais)? Are you sure the database is opened? Check msgInfo( oData:used()) also.

Regards,
James
Colin Haig
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: Picklist

Post by Colin Haig »

Hi James

Yes the database is open because if I enter a known value the correct data is returned

enter CH and name Colin Haig returned - if I enter C this is when the picklist is invoked.

MsgInfo(oData:cAlias) == 'TDF005'
MsgInfo(oData:used()) == .t.

Regards

Colin
User avatar
James Bott
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Picklist

Post by James Bott »

Try changing this line:

cLine += "cValToChar("+aFields[i] + if( i < len( aFields ), "),", ")" )

To this:

cLine += "cValToChar(oData:"+aFields[i] + if( i < len( aFields ), "),", ")" )

James
Colin Haig
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: Picklist

Post by Colin Haig »

Hi James

I tried that before but I tried it again but the error message is the same except
instead of "intls" not found = oData not found.

Cheers

Colin
Post Reply