Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing all values of a field

Status
Not open for further replies.

bobsmallwood

Programmer
Aug 9, 2001
38
US
Is there code that could be attached to a pushbutton that would change all True values of a field in a table to blank?
 
You could do it two ways.

The first would be to attach some query code to a button and use the changeto keyword.

Code:
var 
qVar   query
endvar
;
qVar = Query
; 
:myAlias:myTable.db  | myField              |
                     | True, changeto Blank |
;
endQuery
;
qVar.executeQBE()


The second would involve using a tCursor and a scan loop. Both should work just fine.

Code:
var
 tc   tCursor
endVar
;
tc.open(":myAlias:myTable.db")
tc.Edit()
;
scan tc:
 if tc."myField" = "True"
    then   tc."myField"  = ""
 endif
endscan
;
tc.endEdit()
tc.close()



Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Just for the sake of completeness...

If you're using Paradox 5.0 or later, you can also use a SQL query, as shown in the following code sample:

Code:
method pushButton(var eventInfo Event)
var
   sq     SQL
   db     Database
endVar

   db.open()
   sq = SQL

      update
         ":work:blanktst.db" t
      set
         t."Value" = null
      where
         t."Value" = True

   endSQL

   if not sq.executeSQL( db ) then
      errorShow( "Can't Blank Field",
                 "Click [>>] for details..." )
   endIf

endMethod

Please note that while QBE queries assume you're working with the local database (e.g. the filesystem of the PC you're running this from), SQL queries need a database variable.

Also, you may find it necessary to quote all table and field names in SQL queries, especially if you use spaces or SQL reserved words in your field names.

To open a Database variable against the local file system, call open with no parameters.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top