Hi All,
1st foray into Access, so go easy on me.
I have some code at the moment which essentially takes the value slected from a datepicker and enters it into a text box which would otherwise be locked (to prevent the users entering garbage data). I have included a copy of the code below, but essentially this is generating an error message when trying to re-lock the text box stating "You can't lock a control while it has unsaved changes".
I know I could get around this by moving the focus elsewhere prior to this line of code running, but I wanted to know if there was another way to achieve this as doing it that way seems like a bit of a fudge?
1st foray into Access, so go easy on me.
I have some code at the moment which essentially takes the value slected from a datepicker and enters it into a text box which would otherwise be locked (to prevent the users entering garbage data). I have included a copy of the code below, but essentially this is generating an error message when trying to re-lock the text box stating "You can't lock a control while it has unsaved changes".
I know I could get around this by moving the focus elsewhere prior to this line of code running, but I wanted to know if there was another way to achieve this as doing it that way seems like a bit of a fudge?
Code:
If PickerValueDate > VerDate Then
MsgBox "Date selected cannot be in the future", vbExclamation, "Input Error"
dtpFrom.Enabled = False
txtDateFrom = ""
Exit Sub
Else
' Transfer date from date picker to text box
txtDateFrom.Locked = False
strDate = Format(dtpFrom, "dd/mm/yyyy")
txtDateFrom = strDate
txtDateFrom.Locked = True
dtpFrom.Enabled = False
End If