Clear Data In columns

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a macro or code that will just delete info in a
column. I have a form that has 4 columns, want to keep
info in the first 2 columns, but want the info in the last
2 to be cleared out after printing. Tried a delete query,
but it seems to clear out the whole record (All columns).
Thank you...
 
Is there a macro or code that will just delete info in a
column. I have a form that has 4 columns, want to keep
info in the first 2 columns, but want the info in the last
2 to be cleared out after printing. Tried a delete query,
but it seems to clear out the whole record (All columns).
Thank you...

Use an update query to set the columns to null.

CurrentDb.Execute "UPDATE MyTable " _
& "SET thirdcolumn = Null, fourthcolumn = Null; " _
, DbFailOnError

- Jim
 
How do you type this in a Update Query? Do you type it in
the Update to: or Criteria field. I typed in both places
and got error messages. I changed info to match my table
and fields. Thanks! >-----Original Message-----
 
No, that is VBA code that executes the Update query. You would run
this in some event - perhaps the event that does the printing, or you
could use a command button.

CurrentDb is a function that returns an object variable to the
database. Execute is a method of the database object that executes an
action query - in this case an update query. The dbFailOnError option
of the Execute method will roll back the update if there is a problem
- and let you know. So if you copy and paste the expression that I
supplied into the appropriate event and change the field names
(thirdcolumn, fourthcolumn) to the actual one you use then it should
do what you want.

- Jim
 
Thanks so much! It works!!!!!
-----Original Message-----
No, that is VBA code that executes the Update query. You would run
this in some event - perhaps the event that does the printing, or you
could use a command button.

CurrentDb is a function that returns an object variable to the
database. Execute is a method of the database object that executes an
action query - in this case an update query. The dbFailOnError option
of the Execute method will roll back the update if there is a problem
- and let you know. So if you copy and paste the expression that I
supplied into the appropriate event and change the field names
(thirdcolumn, fourthcolumn) to the actual one you use then it should
do what you want.

- Jim



.
 
Back
Top