Update a table with code

J

jean

Hi

I know how to update a table with an update query.

Is there another way like some code that i can assign to a button that
would update the table when clicked ?

Name of the table is "TblData" fields name is "FRate" and I want to
update field "FRate" to 0 (zero) when user click on the button

thanks
 
A

Al Campagna

Jean,
Since you don't indicate any logic as to which FRate values need
changing to 0 or not,
I'll assume that you want all FRate values to be set to 0.
A simple method is to create an Update query (in query design mode) that
accomplishes that, and then
select View/SQL View.
Grab the SQL statement, and paste it into your button's On Click code...

Private Sub cmdSEtFrateToZero_Click()
DoCmd.RunSQL "UPDATE tblData SET tblData.FRate = 0;"
End Sub

(You can delete the query you built in order to develop the SQL
statement)
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 

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