Hello all I am trying to make a script work the way that I want it too but it's giving me a hard time. I am very new to scripting and I am relying a lot on samples to piece together what I want to do.
The main problem that I am having right now is that the script that I have created will update all records in a table with the given input, but I only want it to update the record that I am currently viewing in the form.
Here is my code....
Code:
Function UpdateTransactionDate() As Boolean
Dim db As Database
Dim LUpdate As String
Dim LMsg As String
Dim LTransactionDt As Date
On Error GoTo Err_Execute
'Query user for Date of R
LMsg = "Enter the Date of R Form __/__/____"
LMsg = LMsg & Chr(10) & Chr(10) & "Format date as: mm/dd/yyyy"
LTransactionDt = InputBox(LMsg)
Set db = CurrentDb()
'Re-Assign Date to TransactionDate
LUpdate = "update [Tasks]"
LUpdate = LUpdate & " set [UpdateDate] = #" & Format(LTransactionDt, "mm/dd/yyyy") & "#"
db.Execute LUpdate, dbFailOnError
Set db = Nothing
MsgBox "Changing the Dates was Successful."
UpdateTransactionDate = True
On Error GoTo 0
Exit Function
Err_Execute:
MsgBox "Updating the dates failed, you will need to enter each date individually."
UpdateTransactionDate = False
End Function
What do I need to change to have it only work with the selected record?
TIA for any help you can give me, this is driving me nuts.
Ultimately I would like to have a button that when pressed will copy a current field to another field on the same record, then prompt for a new ticket number, and a new update date. But I am trying to take baby steps at first and just do one thing per module and then hopefully be able to build a module that will do all of those things in one run.