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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to update tables in Immediate window 1

Status
Not open for further replies.

Soundsmith

Programmer
Feb 21, 2001
84
US
I'm primarily a Fox programmer, and am used to being able to manipulate tables from the 'Command' window. Commands like REPLACE ALL lastdate WITH DATE(), or using SQL SELECTs to extract data from tables (SELECT myTbl.* FROM myTbl WHERE lastname='SMITH' sort of thing.)

How can I perform these manipulations in VBA Immediate window? David 'Dasher' Kempton
The Soundsmith
 
For action queries (INSERT and UPDATE and DELETE), you can use:
DoCmd.RunSql "place your SQL statement here"

You can't do this for SELECT queries, however. The Debug window wouldn't know what to do with the returned recordset.

Another method, one that works for all SQL statements, is to create a new query object (click the Queries tab in the Database Window, then click the New button), switch to SQL view (choose View>SQL from the menu), and type your SQL statement in there. Then choose Query>Run from the menu. To type in a new SQL statement, choose View>SQL again. You could just leave the query window open as a scratch pad, similar to VFP's command window. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top