Update Button

Tumby

Registered User.
Local time
Yesterday, 19:53
Joined
Jan 12, 2009
Messages
64
In a form I have box which does a calculation based on another box.

To update this field in the table I have created an update query.

However when a new record is added to the form, the user will have to run this query to update the table.

I would like to create a button that when clicked would update the table.
I tried to make the source for the button a macro but cannot find the appropiate actions to enter in the macro.

Please how can I do this?
 
Instead of making a button, use vba on the form_load and form_current so that every time the form is opened or moved to another record, the calculation is made. Then just refresh the form (or specific field) to show changes.
for example

Private Sub Form_Current()
Me.TextBox1.Value = Me.TextBox2.Value
Me.Refresh
End Sub

This updates a one text box from the value of another. You can do calculations and other fun things, but this is just the basis. It then refreshes the form so all changes are reflected form wide. Also apply to Form_Load
If you still need to make it button functional, use

Private Sub Command1_Click()

Where the command1 is the name of the button. You can include your sql function and run it using DoCmd.RunSQL (strSQL) which you can find info on elsewhere in the forums.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom