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

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
 
J

John Vinson

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;
 
V

Van T. Dinh

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top