How to show/hide tab without using on current event? (1 Viewer)

gojets1721

Registered User.
Local time
Yesterday, 16:21
Joined
Jun 11, 2019
Messages
430
This is in a similar vein to a post I made yesterday. I inherited a DB which has a bunch of code in the 'on current' event of a single record form, which causes the form to flicker when changing records. When I comment out the code, the flicker goes away so I'm trying to figure out alternatives to current code.

The form has a tab control with 8 tabs, but 4 of the tabs are set to show/hide depending on one field's content in the form. This is handled in the on current event via:

Code:
    If Category = "Timeliness" Then
        tabTimelinessComplaint.Visible = True
    Else
        tabTimelinessComplaint.Visible = False
    End If

Any suggestions on how to accomplish this show/hide result without having to utilize the on current event?
Thanks!
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:21
Joined
Oct 29, 2018
Messages
21,476
Since it depends on the value for each record, using the Current event is correct. To eliminate the flicker, try disabling the control instead of hiding it.
 

gojets1721

Registered User.
Local time
Yesterday, 16:21
Joined
Jun 11, 2019
Messages
430
Since it depends on the value for each record, using the Current event is correct. To eliminate the flicker, try disabling the control instead of hiding it.
Thank you!
 

gojets1721

Registered User.
Local time
Yesterday, 16:21
Joined
Jun 11, 2019
Messages
430
Curious if you could help me with this last bit of 'on current' code.....

The form has a custom nav box which shows what record the user is on. The following code is in the 'on current' code. Any suggestions on if this could be done another way? This is the last bit of code that causes it to flicker. When I remove it, so goes the flicker.

Code:
Dim rst As DAO.Recordset
    Dim lngCount As Long


    Set rst = Me.RecordsetClone


    If Not rst.EOF Then
      With rst
        .MoveFirst
        .MoveLast
        lngCount = .RecordCount
    End With
    End If
    
    Me.txtNavControls = Me.CurrentRecord & " of " & lngCount
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:21
Joined
Feb 19, 2002
Messages
43,302
Very expensive code. Why not just use the built in navigation control? Access is already doing this for you.
 

gojets1721

Registered User.
Local time
Yesterday, 16:21
Joined
Jun 11, 2019
Messages
430
Very expensive code. Why not just use the built in navigation control? Access is already doing this for you.
One of the users is hard of sight and so a custom one was made with much larger text. My understanding was that this was simpler than trying to increase the text of the built in one, as that affected other built in text (again, this is an inherited DB and situation for me so don't shoot the messenger lol)
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:21
Joined
Feb 19, 2002
Messages
43,302
The larger the recordset gets, the slower the code will be. Try moving the code to the Open event. The recordset size won't change unless you filter the form. But if you filter the form, the count will be wrong.

A better solution would be to change the way the form works so it doesn't have to load every record from the table. Maybe bind the form to a query that limits the rows displayed.
 

ebs17

Well-known member
Local time
Today, 01:21
Joined
Feb 7, 2020
Messages
1,949
There may also be a need to use larger buttons for navigation. In this sense, I once found a solution where you use the navigation as a subform in your form. I can't see any flickering there.

If interested, load text file via ...
Code:
Application.LoadFromText acForm, "UFNav", "D:\UFNav.txt"
 

Attachments

  • UFNav.txt
    75.7 KB · Views: 70

Users who are viewing this thread

Top Bottom