ShovelinFishHeads
Registered User.
- Local time
- Yesterday, 20:30
- Joined
- Aug 4, 2016
- Messages
- 57
I am working on some code that is designed to allow a user to switch the value of an ID number associated with a "Status" to the number 6 by simply clicking a cmd button. Button is named 'MakeStatusBillable'. This button is on a form named "MenuItemsLoads" that has a series of ID numbers "written" to a series of text boxes in the header of the form when the form is opened.
The relevant text box involved is named "txtBookingIDFilter"
Since the Update is designed to update the ID number in only one record at a time, I have written some SQL for an Update query that also incorporates "BookingID" as a parameter. See below:
Private Sub MakeStatusBillable_Click()
Dim UpdateSQL As String
UpdateSQL = "UPDATE WatchListQuery SET WatchListQuery.LoadStatusID = 6 WHERE (((WatchListQuery.LoadStatusID)=1 Or (WatchListQuery.LoadStatusID)=2 Or (WatchListQuery.LoadStatusID)=3 Or (WatchListQuery.LoadStatusID)=4 Or (WatchListQuery.LoadStatusID)=5) AND ((WatchListQuery.BookingID)=Eval([MenuItemsLoads]![txtBookingIDFilter])));"
DoCmd.SetWarnings False
DoCmd.RunSQL UpdateSQL
DoCmd.SetWarnings True
End Sub
My question is how do I make this work so that Access doesn't ask me for the BookingID number when the code is run? What am I missing here? Is some other method required?
Thanks everyone!
The relevant text box involved is named "txtBookingIDFilter"
Since the Update is designed to update the ID number in only one record at a time, I have written some SQL for an Update query that also incorporates "BookingID" as a parameter. See below:
Private Sub MakeStatusBillable_Click()
Dim UpdateSQL As String
UpdateSQL = "UPDATE WatchListQuery SET WatchListQuery.LoadStatusID = 6 WHERE (((WatchListQuery.LoadStatusID)=1 Or (WatchListQuery.LoadStatusID)=2 Or (WatchListQuery.LoadStatusID)=3 Or (WatchListQuery.LoadStatusID)=4 Or (WatchListQuery.LoadStatusID)=5) AND ((WatchListQuery.BookingID)=Eval([MenuItemsLoads]![txtBookingIDFilter])));"
DoCmd.SetWarnings False
DoCmd.RunSQL UpdateSQL
DoCmd.SetWarnings True
End Sub
My question is how do I make this work so that Access doesn't ask me for the BookingID number when the code is run? What am I missing here? Is some other method required?
Thanks everyone!