How do I get a Tab Control's Tab to show if there is data inside the Tab? (1 Viewer)

Cark

Registered User.
Local time
Today, 10:38
Joined
Dec 13, 2016
Messages
153
I have a Tab Control on a Form with 3 Tabs which I want the user to fill in to populate the database.

As part of this, I would like to give the user an indicator as to what Tabs already have data added into them and which ones do not and therefore need looking at.

I have a few questions based on my current idea to achieve this, but if anyone has any other ways of achieving this, let me know.

Is there a way to change the Tab Colour to a gradient fill to have a green / red gradient at the bottom?

Is there a way to change just the bottom border of an individual Tab Control Tab? For example change General Information's bottom border to be green like in the Edited picture?
 

Attachments

  • TablControlEdited.PNG
    TablControlEdited.PNG
    59.5 KB · Views: 94
  • TablControlUnedited.PNG
    TablControlUnedited.PNG
    4.6 KB · Views: 105

Ranman256

Well-known member
Local time
Today, 13:38
Joined
Apr 9, 2015
Messages
4,339
Wen the master form loads, do a Dcount on the queries each tab will be using,
Then color them:
Code:
If dcount("*","qsQry1")>0 then
   'Green
Else
    'Red
Endif
 

Cark

Registered User.
Local time
Today, 10:38
Joined
Dec 13, 2016
Messages
153
That will just colour the entire Tab though won't it? I'm looking for a sutble gradient shading / a line at the bottom of the Tab name.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:38
Joined
Sep 21, 2011
Messages
14,045
Perhaps you could use a picture?, but when I tried it puts the tab name to the right of the picture?

You would need to put the tab name in the picture.?

HTH
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:38
Joined
Oct 29, 2018
Messages
21,358
Hi. The only thing I could think of is to use a pseudo Tab control instead, because I am not sure you can do this with the built-in Tab control. Sorry.
 

Cark

Registered User.
Local time
Today, 10:38
Joined
Dec 13, 2016
Messages
153
Just to check what you mean by a "pseudo tab" - you mean a load of Text Boxes / Buttons with some VBA Script going with it to make something look like the native Tab Control Object?
 

jdraw

Super Moderator
Staff member
Local time
Today, 13:38
Joined
Jan 23, 2006
Messages
15,364
I had an older application with a requirement along the lines you describe. Basically, for edit/adjustment to records where some information exists, put a small box above the Tabs. If on the current record tab has data, color the box green, if there is no data, color the box black or some color perhaps matching the form background.
I have attached an example showing the affect where Tab EnglishAlliance has text, and Tab FrenchProfile does not.

Good luck with your project.
 

Attachments

  • TabsLines.png
    TabsLines.png
    20.5 KB · Views: 109
Last edited:

Cark

Registered User.
Local time
Today, 10:38
Joined
Dec 13, 2016
Messages
153
I've gotten the attached image set up so far.

I am now going to try tweaking it to change the length of the red/green bar to represent how many fields are still to be filled in.

Any tips for code to do this would be appreciated.
 

Attachments

  • Capture.PNG
    Capture.PNG
    2.3 KB · Views: 121

jdraw

Super Moderator
Staff member
Local time
Today, 13:38
Joined
Jan 23, 2006
Messages
15,364
Is there a set number of fields/controls that must have values to be accepted?
What fields/controls are on the tab in question?
How do you currently determine if field or fields are empty?
You could have a routine to count those controls with no values and present/display either by line length or a number ---just a thought for consideration.
 
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:38
Joined
May 21, 2018
Messages
8,463
Several examples of coloring tab controls and tabs.
 

Attachments

  • MajP TabControlColor.mdb
    508 KB · Views: 121

Gasman

Enthusiastic Amateur
Local time
Today, 17:38
Joined
Sep 21, 2011
Messages
14,045
I've gotten the attached image set up so far.

I am now going to try tweaking it to change the length of the red/green bar to represent how many fields are still to be filled in.

Any tips for code to do this would be appreciated.

How are you doing it in the first place?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:38
Joined
Oct 29, 2018
Messages
21,358
Just to check what you mean by a "pseudo tab" - you mean a load of Text Boxes / Buttons with some VBA Script going with it to make something look like the native Tab Control Object?
Hi. That's correct. However, if you do find a way to do it using the built-in tab control, please do let us know. Good luck!
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:38
Joined
May 21, 2018
Messages
8,463
This works for me as a generic way determine how many required controls are on each page and how many are filled in. Then you pass in to the sub the specific rectangle, a reference to the tab control, and the page on the the tab. This will resize the box for that tab. Just tag each control that are required to be filled out.

Code:
Private OriginalWidth ' Set this on load

Private Sub Resizebox(bx As Access.Rectangle, ThetabControl As Access.TabControl, SelectedTab As Integer)
  'Tell it what box to format, and which tab
  On Error GoTo errlbl
  Dim ctrl As Access.Control
  Dim ctrlsOnPage As Integer
  Dim ctrlsFilledInOnPage As Integer
  For Each ctrl In Me.Controls
    'Tag controls you want to fill in. I use a ?
    If ctrl.Tag = "?" Then
       If ctrl.Parent Is ThetabControl.Pages(SelectedTab) Then
         ctrlsOnPage = ctrlsOnPage + 1
         If Not IsNull(ctrl.Value) Then ctrlsFilledInOnPage = ctrlsFilledInOnPage + 1
       End If
    End If
  Next ctrl
  bx.Width = Originalwidth * (ctrlsFilledInOnPage / ctrlsOnPage)
 ' Debug.Print ctrlsFilledInOnPage & " " & ctrlsOnPage
  Exit Sub
errlbl:
  If Err.Number = 438 Then
    'no parent property
    Resume Next
  Else
    Debug.Print Err.Number & " " & Err.Description
  End If
End Sub

@DBguy
Instead of getting rid of the tab control completely you can format a tab control without any buttons. So you get all the benefits of a tab control, but you can make your own buttons. Then you need very little code, you just have your buttons set the value of the tab control. If you look at the example I posted it uses this to allow multiple colored tabs.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:38
Joined
Oct 29, 2018
Messages
21,358
@DBguy
Instead of getting rid of the tab control completely you can format a tab control without any buttons. So you get all the benefits of a tab control, but you can make your own buttons. Then you need very little code, you just have your buttons set the value of the tab control. If you look at the example I posted it uses this to allow multiple colored tabs.
That's a cool way to get around the problem. Thanks!
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:38
Joined
May 21, 2018
Messages
8,463
FYI. It is a real pain to design with no tabs. So do all design before removing them.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:38
Joined
May 21, 2018
Messages
8,463


So here is an example where under each tab there is a bar showing percent of required fields filled in. It will update when you update a field. Adding additional tabs requires adding a label, rectangle, and tagging the controls. No additional code.


In the image 50% of controls on tab 2 are filled in.
 

Attachments

  • TabsFilledIn.accdb
    488 KB · Views: 99
  • completion.jpg
    completion.jpg
    20.2 KB · Views: 224
Last edited:

Cark

Registered User.
Local time
Today, 10:38
Joined
Dec 13, 2016
Messages
153
How are you doing it in the first place?


At the moment I am using a snippet of code which is triggered when a Field is entered into the Sub Form. So when I enter data in the FrmSubReliability, the ReliabilityProgressBar

The code that is fired on the AfterUpdate event is:
Code:
    If [Forms]!FrmOverview.TabCtl12 = 1 _
    Then
    Debug.Print "FollowedThenPath"
        If Nz(Forms!FrmOverview!FrmSubReliability.Form!PartID, 0) = _
           Nz(Forms!FrmOverview!FrmSubCoverInformation.Form!PartID, 0) And _
           Trim(Forms!FrmOverview!FrmSubReliability.Form!Title & "") <> vbNullString _
        Then
            Forms!FrmOverview!ReliabilityProgrammePresent = -1
            Forms!FrmOverview!ReliabilityProgress.BackColor = RGB(33, 255, 44)
        Else
            Forms!FrmOverview!ReliabilityProgrammePresent = 0
            Forms!FrmOverview!ReliabilityProgress.BackColor = RGB(255, 43, 43)
        End If
    Else
    Debug.Print "FollowedElsePath"
    End If

This simply changes the colour of the bar to red or green. The tweaking I am wanting to make will make it change the bar length based on the number of Fields filled in.

I really appreciate all the responses in this thread. It seems to have sparked quite a bit of discussion over the weekend... just frustrated I didn't get chance to check the messages over the weekend to respond sooner.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:38
Joined
Sep 21, 2011
Messages
14,045
I think MajP has done all the hard work for you?
 

Users who are viewing this thread

Top Bottom