D
DS
I want to run an UPDATE based on field values. I'm not quite sure how.
DoCmd.SetWarnings False
Dim RSQL As String
RSQL = "UPDATE tblInfoItem SET [ItemPrice] =
([ItemPrice]*[TxtPercentChange])-[ItemPrice]" & _
"WHERE tblInfoItem.[TermID] = Forms!frmPriceChanger!TxtTerminal " & _
"AND tblInfoItem.MenuID = Forms!frmPriceChanger!TxtMenu " & _
"AND tblInfoItem.MenuCatID = Forms!frmPriceChanger!TxtSection " & _
"AND tblInfoItem.TypeID = Forms!frmPriceChanger!TxtType " & _
"AND tblInfoItem.DayID = Forms!frmPriceChanger!TxtDay;"
DoCmd.RunSQL (RSQL)
The problem is if any of the Txt* fields are left unfilled (they have a
0 as a default) I don't want them to be included in the UPDATE. So if
TxtMenu is left blank that means TxtMenu should not be included in the
WHERE part of the statement.
Any help appreciated.
Thnaks
DS
DoCmd.SetWarnings False
Dim RSQL As String
RSQL = "UPDATE tblInfoItem SET [ItemPrice] =
([ItemPrice]*[TxtPercentChange])-[ItemPrice]" & _
"WHERE tblInfoItem.[TermID] = Forms!frmPriceChanger!TxtTerminal " & _
"AND tblInfoItem.MenuID = Forms!frmPriceChanger!TxtMenu " & _
"AND tblInfoItem.MenuCatID = Forms!frmPriceChanger!TxtSection " & _
"AND tblInfoItem.TypeID = Forms!frmPriceChanger!TxtType " & _
"AND tblInfoItem.DayID = Forms!frmPriceChanger!TxtDay;"
DoCmd.RunSQL (RSQL)
The problem is if any of the Txt* fields are left unfilled (they have a
0 as a default) I don't want them to be included in the UPDATE. So if
TxtMenu is left blank that means TxtMenu should not be included in the
WHERE part of the statement.
Any help appreciated.
Thnaks
DS