Updating a table's field using data from other field's values with a query in VBA (1 Viewer)

Shinta

Registered User.
Local time
Today, 02:51
Joined
Jan 11, 2012
Messages
48
I've ALREADY solved this; the code I'm posting worked for me; I hope that it would be of help for any other one with my same issue.

Thanks a lot for all the gentle interest of all the crew at this forum: you guys really encourage us to keep forward with you sincere concern! :D


-----------------------------------------------------------------------------------

Greetings:

What I'm trying to do is to take the data from two fields in a table, multiply them, and store the result in a third field of the same registry. For such a thing, I'm using an UPDATE query with VBA.

The logic flow is as follows:

+ Store the value of TextField1 (from MyForm), to tableField2.
+ Multiply the content of tableField1 with the value of TextField1 and store it at tableField3.
+ Include the criteria in the WHERE expression so the query will include the registries I'm interested to be affected.

What I've tried is the following:

Code:
CurrentDb.Execute "UPDATE MyTable SET [tableField2] = " & Me.MyTextBox1 & ", [tableField3] = ([tableField1] * " & Me.MyTextBox1 & ") WHERE ((tableField4 = """ & "MyCriteria" & """) AND (id = " & Me.tableID & "))"

Thanks a lot in advanced.

Regards :)
 

Users who are viewing this thread

Top Bottom