S
SimonT
Hi Guys,
I am converting a access application over to a SQL BE setup and am having to
convert a number of update queries, I previously had a query to update
product prices and now need to convert to SQL to replace the query, and have
written the code but cannot figure out why its no working, can anyone help
please?
This is my code:
Private Sub cmdUpdate_Click()
Dim rsProducts As DAO.Recordset
Dim rsPrices As DAO.Recordset
Dim strSQLPR As String
Dim strSQLCP As String
Set rsProducts = CurrentDb.OpenRecordset("products", dbOpenDynaset,
dbSeeChanges)
Set rsPrices = CurrentDb.OpenRecordset("tblPrices", dbOpenDynaset,
dbSeeChanges)
strSQLPR = "UPDATE products " & vbCrLf
strSQLPR = strSQLPR & " SET products.price =
[price]+[Forms].frmModify].[txtchange] " & vbCrLf
strSQLPR = strSQLPR & " WHERE
(((products.productID)=[Forms].[frmPriceModify].[productID])); "
DoCmd.RunSQL strSQLPR
strSQLCP = "UPDATE tblPrices " & vbCrLf
strSQLCP = strSQLCP & " SET tblPrices.price =
[price]+[Forms].frmModify].[txtchange] " & vbCrLf
strSQLCP = strSQLCP & " WHERE
(((tblPrices.productID)=[Forms].[frmPriceModify].[productID])); "
DoCmd.RunSQL strSQLCP
[Forms]![frmPriceModify]![price].Requery
rsProducts.Close
rsPrices.Close
Set rsProducts = Nothing
Set rsPrices = Nothing
End Sub
Many thanks
Si
I am converting a access application over to a SQL BE setup and am having to
convert a number of update queries, I previously had a query to update
product prices and now need to convert to SQL to replace the query, and have
written the code but cannot figure out why its no working, can anyone help
please?
This is my code:
Private Sub cmdUpdate_Click()
Dim rsProducts As DAO.Recordset
Dim rsPrices As DAO.Recordset
Dim strSQLPR As String
Dim strSQLCP As String
Set rsProducts = CurrentDb.OpenRecordset("products", dbOpenDynaset,
dbSeeChanges)
Set rsPrices = CurrentDb.OpenRecordset("tblPrices", dbOpenDynaset,
dbSeeChanges)
strSQLPR = "UPDATE products " & vbCrLf
strSQLPR = strSQLPR & " SET products.price =
[price]+[Forms].frmModify].[txtchange] " & vbCrLf
strSQLPR = strSQLPR & " WHERE
(((products.productID)=[Forms].[frmPriceModify].[productID])); "
DoCmd.RunSQL strSQLPR
strSQLCP = "UPDATE tblPrices " & vbCrLf
strSQLCP = strSQLCP & " SET tblPrices.price =
[price]+[Forms].frmModify].[txtchange] " & vbCrLf
strSQLCP = strSQLCP & " WHERE
(((tblPrices.productID)=[Forms].[frmPriceModify].[productID])); "
DoCmd.RunSQL strSQLCP
[Forms]![frmPriceModify]![price].Requery
rsProducts.Close
rsPrices.Close
Set rsProducts = Nothing
Set rsPrices = Nothing
End Sub
Many thanks
Si