Clearing data in a table

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

Guest

Hi,

I have a table with various fields that I want the user to be able to remove
the data with the click of a button. What I want is a form with command
buttons that when the user clicks on a button it removes the data from a
given field. I know this must be easy, but I can't figure out the code for
"looping" though a table in order to change the data. If you can help it
would be appreciated.

Thanks,
 
Phil

I may be missing something, but what you described sounds like it would
require a button for each field that the user might want to "empty".

Is there a reason why you can't have the user highlight the field and press
the <Delete> button?
 
Hi Jeff,

After I pressed the "Post" button I realized that I was not clear on one
thing. I want each button to clear a given field in ALL the records of the
table. So, based on the button clicked on I need to loop through each record
in the table and clear the given field.

Thanks
 
Phil said:
Hi Jeff,

After I pressed the "Post" button I realized that I was not clear on one
thing. I want each button to clear a given field in ALL the records of the
table. So, based on the button clicked on I need to loop through each record
in the table and clear the given field.

No, you don't. Use a single update query to clear them all at once.

UPDATE TableName SET FieldName = Null
 
Hi Rick,
sorry, but I don't understand. Is this something that can be run from a
command button on the form? That's what I want to do. I've never used an
update query and don't know how to use it.

Thanks again,
 
Phil said:
Hi Rick,
sorry, but I don't understand. Is this something that can be run from a
command button on the form? That's what I want to do. I've never used an
update query and don't know how to use it.

Thanks again,

Well, you should really open up the query designer (and the Help file) and
become familiar with "Action Queries". These include MakeTable, Append,
and Update queries. You can run the SQL in code from a command button like
this...

CurrentDB.Execute "UPDATE TableName SET FieldName = Null", dbFailOnError

If you had a saved action query in your app, the SQL string in the above
could be replaced with the name of that saved query and it would also work.
 
Access is so powerful try video professer for 64.00 It has a good section on
building a queries.
 
Back
Top