Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select table name from Combo
Message
De
24/06/2005 06:43:33
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
23/06/2005 03:25:44
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows '98
Network:
Windows 98
Database:
Visual FoxPro
Divers
Thread ID:
01025722
Message ID:
01026212
Vues:
13
>Dear Experts
>
>I have a combobox that holds following values
>
>620
>621
>622
>623
>624
>
>and tables with above names are in Data Environment like
>620.dbf and 621.dbf etc.
>
>On the click event of command1, I have following codes
>
>db1=alltrim(thisform.combo2.value)
>
>select *;
>from &db1;
>where phone=thisform.text1.value;
>into cursor abc
>
>
>But when I run this command then it shows this error message
>
>File ‘620.dbf’ does not exists
>
>Please modify my query

Robert,
Reread the error message. It says "File '620.dbf' does not exists"
Either:
-Supply the path
-Set database to database of your tables
-Since it's in your dataenvironment use the corresponding alias.
etc

Important: Use name expression for table names rather than macro substitution.

select *;
from (m.db1) ;
where phone=thisform.text1.value;
into cursor abc

Sample:
* Combo2.init
Local Array aDEMembers[1]
Local lnMembers,ix,lcMembers
lnMembers = Amembers(aDEMembers,Thisform.DataEnvironment,2)
With Thisform.DataEnvironment
  For m.ix=1 To m.lnMembers
    With Evaluate('.'+aDEMembers[m.ix])
      If Lower(.BaseClass) == 'cursor' ;
          and Inlist(Val(Juststem(.CursorSource)),620,621,622,623,624)
        Select (.Alias)
        This.AddListItem(Juststem(.CursorSource),m.ix,1)
        This.AddListItem(.Alias,m.ix,2)
        This.AddListItem(Dbf(),m.ix,3)
      Endif
    Endwith
  Endfor
Endwith

* Some method where your code was, ie: a button click
Local lcValue, lcAlias, lcDbf
With Thisform.Combo2
  lcValue = .Value
  lcAlias = .List(.ListIndex,2)
  lcDbf   = .List(.ListIndex,3)
Endwith

TEXT to m.lcMsg textmerge noshow
Selected value: <<m.lcValue>>
Alias: <<m.lcAlias>>
Table: <<m.lcDBF>>
ENDTEXT
Messagebox( m.lcMsg )

Select *;
  from (m.lcDbf);
  into Cursor abc
Browse
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform