Clear Data In columns

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...
 
J

Jim Allensworth

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
 
G

Guest

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-----
 
J

Jim Allensworth

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
 
G

Guest

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



.
 

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