Problem with combo

Problem with combo

Postby Silvio » Sat Apr 23, 2011 1:05 pm

I use two combo to show all cities of my Region

If I select first combo I can select a Province sample "TE" and it reload the second Combobox with all cities of this province "TE"

as you can see in this picture :


Image

then I can save all data into a dbf good

the problem is at Init

1. when on modify I set the combo value with cstring

cProvincia := RU->RUPRV
cComune := RU->RULOC

while I can see the first combo with the value ( see the picture ) on second combobox I not see the value ....


2. the second problem is I can see the first combobox value but if I select with the mouse on the second combobox I cannot select any items


I must click on first combo and reselect the province , then it reload the aitems of second combobox



this is the test sorce code :

Code: Select all  Expand view


#Include "Fivewin.ch"


  REQUEST DBFCDX
  REQUEST DBFFPT
  EXTERNAL ordkeyno, ordkeycount,ordcreate,ordkeygoto


Function Main()
   Local oFrmVds, oCbx1, oCbx2
   LOCAL aPROVINCE:={}
   LOCAL aCOMUNI:={}
   local cProvincia := ""
   local cComune := ""
   RddSetDefault( "DBFCDX" )




   USE COMUNI ALIAS COMUNI
  INDEX ON  COMUNI->PROVINCIA TAG PROV TO COMUNI // Sure you don´t need to create this index every time

  USE PROVINCE ALIAS PROVINCE
   index on PROVINCE->SIGLA tag prov to PROVINCE
  DO WHILE ! PROVINCE->(EoF())
     AAdd( aPROVINCE,( TRIM(PROVINCE->SIGLA)))
     PROVINCE->(DbSkip())
  ENDDO
  CLOSE PROVINCE


     if ! Db_Open("RUX","RU")
      return nil
   endif
   cProvincia :=  RU->RUPRV
   cComune    :=    RU->RULOC


   Define DIALOG oFrmVds TITLE "  TEST COMUNI " ;
       FROM 452, 774 to 950, 1539 PIXEL

   @ 82,  11 SAY "Provincia di nascita :" SIZE  55,   7 PIXEL  OF oFrmVds  COLOR 0, 14215660
   @ 81,  61 COMBOBOX oCbx1 VAR cProvincia ITEMS  aPROVINCE SIZE  30,  90 PIXEL OF oFrmVds COLOR 0, 16777215 ;
         ON CHANGE Reload(@oCbx2, @aComuni, cProvincia)

   @ 82,  95 SAY "Comune di nascita :" SIZE  55,   7 PIXEL  OF oFrmVds  COLOR 0, 14215660
   @ 81,  165 COMBOBOX oCbx2 VAR cComune ITEMS  aComuni SIZE  100,  80 PIXEL OF oFrmVds COLOR 0, 16777215

   @ 205, 168 BUTTON oBtn PROMPT "Conferma" OF  oFrmVds SIZE 40, 10 PIXEL  DEFAULT  ACTION   ( oFrmVds:end( IDOK ) )
   @ 205, 212 BUTTON oBtn PROMPT "Annulla" OF  oFrmVds SIZE 40, 10 PIXEL  CANCEL ACTION  ( oFrmVds:end( IDCANCEL ) )
   ACTIVATE DIALOG oFrmVds   RESIZE16 CENTERED ON INIT (oCbx1:bCloseUp:=oCbx1:bChange)

   if oFrmVds:nresult == IDOK

      Replace RU->RULOC      with  cComune
      Replace RU->RUPRV      with cProvincia
    endif
 RETURN NIL

// Function to reload the  second combobox
Static Function Reload(oCbx, aItems, cProv)
  aItems:={}
   USE COMUNI ALIAS COMUNI NEW

  Comuni->(DbSetFilter({|| Comuni->Provincia==cProv}))
  Comuni->(DbGoTop())
  OutputDebugString("Reloading Comuni for Prov. "+cProv)
  Do While Comuni->(!Eof())
     AAdd( aItems, RTrim(Comuni->Localita))
     Comuni->(DbSkip())
  EndDo
  OutputDebugString("Reloaded " +Str(Len(aItems))+" Comuni for Prov. "+cProv)
  oCbx:SetItems(aItems)

   CLOSE Comuni
return .t.


 function Db_Open(cDbf,cAlias)

       USE &(cDbf+".dbf")      ;
         INDEX &(cDbf+".cdx") ;
         ALIAS &(cAlias) NEW
      return .t.



 



If you want dbfs I can send you because are big !!!
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Problem with combo

Postby Daniel Garcia-Gil » Sat Apr 23, 2011 1:33 pm

Silvio

you can use METHOD Select( nItem )

Code: Select all  Expand view
oCbx:Select( 1 )
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Problem with combo

Postby Silvio » Sat Apr 23, 2011 6:32 pm

Error description: Error BASE/1004 Class: 'NIL' has no exported method: SELECT
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Problem with combo

Postby Silvio » Sat Apr 23, 2011 7:30 pm

I sent you the test complete
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Problem with combo

Postby Daniel Garcia-Gil » Sat Apr 23, 2011 11:36 pm

Silvio

i saw the test, my suggestion is same

Daniel Garcia-Gil wrote:Silvio

you can use METHOD Select( nItem )

Code: Select all  Expand view
oCbx:Select( 1 )
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Problem with combo

Postby Silvio » Sun Apr 24, 2011 2:54 pm

no daniel
I found the error now
the aarray aComuni was not popolate at init

the problem NOW is this

Now If the user go to the modify of record can you the sigle of province "TE" and the city "TERAMO" on the combobox

but if click on the combobox the user cannot see only the ities of that province but all cities of archive

the user must reselect the first combobox and only then this operation the second combobox I can see only the cities of that province selected

U hope you understood me

p.s. ( post scriptum ) good easter to YOU and your family
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Problem with combo

Postby Silvio » Sun Apr 24, 2011 3:05 pm

I explain you

if I insert

oCbx:select(1)

I can see the first element of cities of province "TE" right

Now you try to save it

you have saved
first combo "TE"
second combo "TERAMO"

when you re- run the test you must go to modify the record you found what you selected BUT

if you click on second combo you can select another cities

BUT if you see good you can select also cities not for "TE" province

the cities of "TE" province are from "ALBA ADRIATICA " TO "VALLE CASTELLANA"

BUT I CAN SELECT ALSO FOR SAMPLE " ALA" IT NOT IS FOR "TE" PROVINCE BUT OF "TA" PROVINCE

i HOPE YOU UNDERSTOOD THE PROBLEM
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Problem with combo

Postby Daniel Garcia-Gil » Sun Apr 24, 2011 4:37 pm

Silvio

the sample you sent me work fine....

only added 1 line

oCbx:Select( 1 )

download sample: http://www.sitasoft.net/fivewin/samples/form.zip
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Problem with combo

Postby Silvio » Sun Apr 24, 2011 9:26 pm

i UNDERSTOOD YOU NOT UNDERSTOOD ME

SORRY FOR THE UPPER LETTERS BUT i WRITE FROM HTC SMARTHPHONE

PLEASE FIRST CHANGE THESE LINES :

USE COMUNI ALIAS COMUNI
INDEX ON COMUNI->PROVINCIA TAG PROV TO COMUNI // Sure you don´t need to create this index every time

Do While Comuni->(!Eof())
AAdd( aComuni, RTrim(Comuni->Localita))
Comuni->(DbSkip())
EndDo

USE PROVINCE ALIAS PROVINCE
index on PROVINCE->SIGLA tag prov to PROVINCE

DO WHILE ! PROVINCE->(EoF())
AAdd( aPROVINCE,( TRIM(PROVINCE->SIGLA)))
PROVINCE->(DbSkip())
ENDDO
CLOSE PROVINCE

I ADD THE LINES ON BOLD






TRY TO MAKE THESE OPERATIONS

OPEN TEST.EXE

SELECT A PROVINCE SAMPLE "TE"
THEN SELECT A CITY SAMPLE "TERAMO"

OK ?

NOW PRESS FIRST BUTTON TO SAVE ON RUX.DBF

CLOSE TEST.EXE

RE OPEN TEST.EXE

WHAT YOU SEE NOW ?

i SEE ON FIRST COMBO "TE" AND ON SECOND "TERAMO"

IF YOU SELECT ON THE SECOND COMBO ANOTHER CITY YOU CAN MAKE IT

BUT YOU CAN SELECT ALL CITIES AND NOT THE CITIES FOR THAT PROVINCE
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Problem with combo

Postby StefanHaupt » Tue Apr 26, 2011 11:05 am

Silvio,

try to fill the array in the ON INIT clause

Code: Select all  Expand view

  cProvincia :=  RU->RUPRV
  cComune    :=    RU->RULOC
  
   Define DIALOG oFrmVds TITLE "  TEST COMUNI " ;
       FROM 452, 774 to 950, 1539 PIXEL
   ...

   ACTIVATE DIALOG oFrmVds   RESIZE16 CENTERED ON INIT (oCbx1:bCloseUp:=oCbx1:bChange, Reload(@oCbx2, @aComuni, cProvincia))

 
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Problem with combo

Postby Silvio » Tue Apr 26, 2011 11:52 am

STEPHAN,
iT SEEMS TO RUN GOOD ON XP

BUT WHEN i TRY IT ON WINDOWS SEVEN IT NOT RUN

THE PROBEM NOW IS WHEN THE USER INSERT A CITY THEN HE SEE THE FIRST CITY OF THE ITEMS NOT THE CITY HE INSERTED
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Problem with combo

Postby Silvio » Wed Apr 27, 2011 7:12 am

Now I insert this

nMode =1 --> new record
nMode=2 --> modify

IF nMode==1
oCbx:Select( 1 ) ok
elseif nMode==2
nPos := AAT( aItems, cloc )
oCbx:Select( nPos ) ok
ENDIF

it run ok but when I click on combo i see all cities
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Willi Quintana and 118 guests