How to erase all data from one column of the table?

  • Thread starter Thread starter Sam Hung
  • Start date Start date
S

Sam Hung

Hi All,

I'm trying to let user input one column (column name:
col1) of the table (table name: table1), but able to erase
those data as I hit the "erase" button.

What's the SQL statement should be looked like?
My wrong SQL statement is written as follows:

"Erase Button"
Dim strSQL as String
strSQL = "delete col1 from table1"
DoCmd.RunSQL strSQL
 
What's the SQL statement should be looked like?
My wrong SQL statement is written as follows:

"Erase Button"
Dim strSQL as String
strSQL = "delete col1 from table1"
DoCmd.RunSQL strSQL

Delete deletes RECORDS from the table. You can't delete a column from
the table (other than by changing the table design and removing the
column altogether); what you apparently want to do is update all
records in the table so that coll is empty, or NULL:

UPDATE table1 SET col1 = NULL;
 
No. You don't want to delete the Field. You want to
UPDATE the values of the Field to Null or if Null is not
allow for the Field, some "whit-space" value.

Try:

UPDATE table1 SET col1 = Null

HTH
Van T. Dinh
MVP (Access)
 
Back
Top