Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
About SQL syntax and compiling (URGENT)
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00466414
Message ID:
00466455
Vues:
11
Kosta,
You can put the method as a form method, and then call it from a button (or anywhere else on the form). I usually build the code for the SQL statement piece by piece:
cFilter = ''
if !empty(thisform.MyCombo1.value)
   cFilter = "MyTable.MyField1 = '" + thisform.MyCombo1.value + "'"
endif

if !empty(thisform.MyCombo2.value)
   if !empty(cFilter)
      cFilter + " .AND. "
   endif
   cFilter = cFilter + "MyTable.MyField2 = '" + thisform.MyCombo2.value + "'"
endif

...   More additions to cFilter

SELECT * from MyTable1 ;
   Where &cFilt ;
   into cursor MyCursor
With this code you only add clauses to the filter if they are needed. If a combo or field is empty it is not included.

One further note: In the code above you see that I added quotes around the value of thisform.MyCombo1.value. You need to add this value as a literal value to the string. If you use the "Thisform..." format the value may go out of scope.

HTH
Barbara

>hi Grigore,
>thanks for the help the 2nd problem is OK, I have do it but 1st problem still continiue where to should i create method on the form or on the combo properties
>i dont understand clearly would like to explain me step by step (i am querying my query on the form with combobox and textboxes..)
>
>if youre still online please reply
>
>Kosta
Barbara Paltiel, Paltiel Inc.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform