Marshall Brooks
Member
- Local time
- Yesterday, 20:07
- Joined
- Feb 28, 2023
- Messages
- 696
I'm going to post this as solved, but I used an odd method and perhaps not the best one ...
I'm adding an audit trail to events on a form: https://www.access-programmers.co.u...update-of-a-field.329588/page-10#post-1909410
I have a command button that displays the audit results, but many of the older records will not have any audit results and never will have any audit results.
So we wanted the button to only be visible if there were results to display.
Previously I could scroll through the records without any issues - I saw the data in the textbox fields change, but nothing else.
I added this code in the forms Form_Current() Event:
It works fine and does what was intended, but when I scroll through the records, the btnHistory is flashing b/c the code has to decide whether to show it or not. And it doesn't matter if the History button is visible by default or not visible by default in the form properties.
The Application.Echo suggestion came from https://www.access-programmers.co.u...n-flashes-flickers-and-form-refreshes.211223/ if I uncomment those lines, the btnHistory doesn't flash at all, but the entire form seems to re-paint when I scroll to a new record.
What seems to work is this:
With this code, the form only has to show/hide the button if it's value is different from it's current value.
There is still a very minor delay before the button appears, but it is negligible.
Hope this helps others and please reply if anyone knows a better solution!!!
I'm adding an audit trail to events on a form: https://www.access-programmers.co.u...update-of-a-field.329588/page-10#post-1909410
I have a command button that displays the audit results, but many of the older records will not have any audit results and never will have any audit results.
So we wanted the button to only be visible if there were results to display.
Previously I could scroll through the records without any issues - I saw the data in the textbox fields change, but nothing else.
I added this code in the forms Form_Current() Event:
Code:
' Hide History Button if no History Records:
'Application.Echo False
If DCount("[REFERENCE]", "qryAuditLogTCTO") = 0 Then
Me.btnHistory.Visible = False
Else
Me.btnHistory.Visible = True
End If
'Application.Echo True
It works fine and does what was intended, but when I scroll through the records, the btnHistory is flashing b/c the code has to decide whether to show it or not. And it doesn't matter if the History button is visible by default or not visible by default in the form properties.
The Application.Echo suggestion came from https://www.access-programmers.co.u...n-flashes-flickers-and-form-refreshes.211223/ if I uncomment those lines, the btnHistory doesn't flash at all, but the entire form seems to re-paint when I scroll to a new record.
What seems to work is this:
Code:
If DCount("[REFERENCE]", "qryAuditLog") = 0 Then
If Me.btnHistory.Visible = True Then Me.btnHistory.Visible = False
Else
If Me.btnHistory.Visible = False Then Me.btnHistory.Visible = True
End If
With this code, the form only has to show/hide the button if it's value is different from it's current value.
There is still a very minor delay before the button appears, but it is negligible.
Hope this helps others and please reply if anyone knows a better solution!!!