This topic is locked

error occured when I try to update a field of another table

3/2/2007 12:02:40 AM
ASPRunnerPro General questions
R
ryoichi_minagawa author

Hello, Please advice what is incorrect in my scripts.
[----- table_a --------].......................[------ table_b ------]

customer (key field)<-----serch------- customer (key field)

address

sales_latest (numeric)<--update----- sales (numeric)
2 tables are in the same MSAccess database.

"tabel_a" and "table_b" are linked by the key field "customer" so that I can jump from "table_a" to "table_b".

Now I am looking a record of table_b in edit mode. I would like to update table_a.sales_latest and table_b.date_of_sales by this record of table_b.
My scrips is as follow.

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

Function BeforeEdit(dict, where)
strSQLUpdate = "update table_a set sales_latest =" & dict("sales") & "where customer =" & dict("customer")

dbConnection.Execute strSQLUpdate
BeforeEdit = True
End Function

J
Jane 3/2/2007

Your code looks right.

You only need to use single quotes around the field if customer field is text.

Function BeforeEdit(dict, where)

strSQLUpdate = "update table_a set sales_latest =" & dict("sales") & " where customer ='" & dict("customer") &"'"

dbConnection.Execute strSQLUpdate
BeforeEdit = True
End Function