Try
Code:If NOT Me.NewRecord then Me.AllowEdits = (Datum = Date) End If
Try
Code:If NOT Me.NewRecord then Me.AllowEdits = (Datum = Date) End If
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
Works perfectly, thank you.
EDIT: It works on every form except one and I don't know why.
It returns this error when I enter the form view.
That form is also very slowly loading and it is very important to me, I can't just ignore it.
Do you have advice to help me fix it?
Access recommends fewer controls
Possibly a corrupt form, if other forms are OK. Try a decompile and compile again.
Try a new DB and import enough to test just that form. Then if good, import everything else.
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
Hello again guys, I just have one question about this code and locking the old records.
We are using it over a month and it works fine, but here is the small problem we've noticed:
When you try to navigate through previous records in the form view, it locks all the old records (like it's supposed to), but when you go back to the today's date, record is also locked for editing in form view
It can be undone with reopening the form, but can it be fixed somehow in the lines of the code?
This is the code in the form's "On current"
Code:Option Compare Database Option Explicit Private Sub Form_Current() If Me!Datum < Now() - 1 Then Me.AllowEdits = False End If End Sub
You did'nt estimate, what happens when condition is false! And you can drop If...End If entirely
...
Me.AllowEdits = (Me!Datum > Now()-1)
...
Or in case you don't want yesterdays entries which are less than 24 hours old (only when field Datum contains time part) to be editable
...
Me.AllowEdits = (Me!Datum >= Date())
...
Works perfectly, thanks!