Question about recursivity and DBF tables... lazarus / 16-Databases ---------------------------------------------------------------------- ecitoyen · 2010-08-01 13:52 Question about recursivity and DBF tables... I have a Combobox with theses item values:  item 1:  TABLE001  item 2:  TABLE002  ...  item 10: TABLE010 also i have 2 Array 10 elements...  CHoiceArray and TableArray Choice Array[0]:= 'TABLE001'; Choice Array[1]:= 'TABLE002'; ... Choice Array[9]:= 'TABLE010'; (This Array is required to build the Combobox item list) and TableArray[0]:= 'TABLE001.dbf'; TableArray[1]:= 'TABLE002.dbf'; ... TableArray[9]:= 'TABLE010.dbf'; All these .dbf tables are located in the same path C:\DBFTABLES\ or (with Linux) /home/username/DBFTABLES/ when i select an item, i got a Combobox.Text equal at... TABLE005(...example) sel: string; sel:=trim(Combobox.Text) After that i have to find wich element(or table name) are corresponding with the user choice... n:=0; RESULT:=0;  for n=1 to 10 do   begin   if sel=trim ChoiceArray[n-1] then    RESULT:=n;   end; and now i just openning the table PATHNAM:='C:\DBFTABLES'; TABLENAME:=TableArray[RESULT-1];   Dbf1.FilePathFull := PATHNAM;   Dbf1.Tablename := TABLENAME;   Dbf1.TableLevel := 7;   Dbf1.Exclusive := False;   Dbf1.Open;          ...   doing what we want to do... with TABLE005.dbf(example)   Dbf1.Close; and now we want to let the user make another choice ...    resetting the ComboBox.Text with    Combobox.Text:= ChoiceArray[0]... If the user choose another table... TABLE004.dbf (example) we will get an error... an access error... the Only way i found to solve the problem was the following... re-lauchn the same program another time... and close the actual program Is it possible to have a DataAccess object  Dbf1: TDbf; with a variable name DbfXXX: Tdbf;? ---------------------------------------------------------------------- ecitoyen · 2010-08-01 14:17 I forgot a thing... with db2K (Visual dBase) it was possible to use variable name for a table... PATHNAM='C:\DBFTABLES' TABLENAME=TableArray[RESULT-1] FULLNAME= PATHNAM & TABLENAME USE FULLNAME ... doing what we want... CLOSE DATABASES At the next time, the program will open and access a new table without any problem...