A Little Help With Tab Control (1 Viewer)

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:30
Joined
Aug 30, 2003
Messages
36,126
It pops up a parameter box for AuditID and when I x out of the parameter box it highlights this code on another form (frm_labtestinput)
Code:
Private Sub Form_Current()
    Me.cboGoToRecord.Value = Me.AuditID.Value
End Sub

The parameter prompt is Access telling you it can't find something, in this case AuditID. Can you attach the db here?
 

psyc0tic1

Access Moron
Local time
Today, 09:30
Joined
Jul 10, 2017
Messages
360
The parameter prompt is Access telling you it can't find something, in this case AuditID. Can you attach the db here?

I figured out why that parameter was popping up but after correcting it I broke the database somewhere and I can't get it fixed so I am starting over at the moment.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:30
Joined
Aug 30, 2003
Messages
36,126
Bummer. Good luck, post back if you need help.
 

psyc0tic1

Access Moron
Local time
Today, 09:30
Joined
Jul 10, 2017
Messages
360
Bummer. Good luck, post back if you need help.

Turns out I broke it by setting the record source of the frm_userprofile to the tbl_users rather than the query qry_userprofile. That created a lot of crazy issues and errors.

I have nothing in there now regarding the delaying of forms loading on database open. I have stripped down and attached a copy of the database for you to look at.

Mind you... the tables are all local now so it will load fast even though when linking them it loads so slow it is prohibitive to use.

Will you please look at it and help make it delay loading of all of the forms on database open?

login with user2, user2 and you will be admin and see all tabs
 

Attachments

  • Test.zip
    595.2 KB · Views: 136
Last edited:

psyc0tic1

Access Moron
Local time
Today, 09:30
Joined
Jul 10, 2017
Messages
360
I tried this code I found:
Code:
Private Sub TabCtl87_Change()

  Select Case TabCtl87.Pages.Item(TabCtl87.Value).Name

    Case "pg0"
      If Len(NewRecordInputForm.SourceObject) = 0 Then
        NewRecordInputForm.SourceObject = "frm_engineerinput"
      End If

    Case "pg1"
      If Len(VisInputForm.SourceObject) = 0 Then
        VisInputForm.SourceObject = "frm_visualinspectioninput"
      End If
    Case "pg2"
      If Len(LabInputForm.SourceObject) = 0 Then
        LabInputForm.SourceObject = "frm_labtestinput"
      End If
    Case "pg3"
      If Len(NewPartForm.SourceObject) = 0 Then
        NewPartForm.SourceObject = "frm_newpartinput"
      End If
    Case "pg4"
      If Len(NewUserForm.SourceObject) = 0 Then
        NewUserForm.SourceObject = "frm_newuserinput"
      End If
    Case "pg5"
      If Len(UserProfileForm.SourceObject) = 0 Then
        UserProfileForm.SourceObject = "frm_userprofile"
      End If
    Case "pg6"
      If Len(ReportCenterForm.SourceObject) = 0 Then
        ReportCenterForm.SourceObject = "frm_newreportcenter"
      End If
    
  End Select

End Sub

but I keep getting a compile error... method or data member not found and highlighting ".SourceObject" in the first case
 

isladogs

MVP / VIP
Local time
Today, 15:30
Joined
Jan 14, 2017
Messages
18,236
Richard

I haven't been involved in this thread & its far too late to join in now ... but I did smile when I read the title & post count ;)
IIRC, I was the person who first suggested you use a tab control.
Hopefully it was the correct decision

Good luck ... I hope you get there soon...
 

Mark_

Longboard on the internet
Local time
Today, 07:30
Joined
Sep 12, 2017
Messages
2,111
2 questions;

What error are you getting?
What exactly are you trying to do?
 

psyc0tic1

Access Moron
Local time
Today, 09:30
Joined
Jul 10, 2017
Messages
360
Richard

I haven't been involved in this thread & its far too late to join in now ... but I did smile when I read the title & post count ;)
IIRC, I was the person who first suggested you use a tab control.
Hopefully it was the correct decision

Good luck ... I hope you get there soon...

I agree that the words a little help are comical with 5 pages of conversation. Things are never as easy as they seem I guess.

I am getting closer to using the tabbed control version of the database... most of the issues are small nit-picky reports and the like and the only stopping point now is making the database load faster.

If I can't get it to load faster I will have to scrap all of the hard work and great help everyone has given
 

MarkK

bit cruncher
Local time
Today, 07:30
Joined
Mar 17, 2004
Messages
8,181
I would do something like this, so there is only one subform control, and clicks on the tab just run code to swap out the current subform in that single control...
Code:
Property Get CurrentPage() As Access.Page
    With Me.Tabctl87
        Set CurrentPage = .Pages(.Value)
    End With
End Property

Private Sub TabCtl87_Change()

    Select Case Me.CurrentPage.Name
        Case "pg0"
            Me.sfm.SourceObject = "frm_engineerinput"
        Case "pg1"
            Me.sfm.SourceObject = "frm_visualinspectioninput"
        Case "pg2"
            Me.sfm.SourceObject = "frm_labtestinput"
[COLOR="Green"]        ' ...[/COLOR]
    End Select

End Sub

I also like to expose the CurrentPage as a property so I don't need to do this code...
Code:
TabCtl87.Pages.Item(TabCtl87.Value).Name

hth
Mark
 

psyc0tic1

Access Moron
Local time
Today, 09:30
Joined
Jul 10, 2017
Messages
360
2 questions;

What error are you getting?
What exactly are you trying to do?

I stated the error I was getting at the bottom of the post.

What I am trying to do is defer the loading of all of the forms on the tabs in the tab control except for one so the db doesn't take 1-5 minutes to open.

The code above is supposed to do that but something is wrong with it.

Error received:
Code:
compile error... method or data member not found and highlighting ".SourceObject" in the first case
 

psyc0tic1

Access Moron
Local time
Today, 09:30
Joined
Jul 10, 2017
Messages
360
I would do something like this, so there is only one subform control, and clicks on the tab just run code to swap out the current subform in that single control...
Code:
Property Get CurrentPage() As Access.Page
    With Me.Tabctl87
        Set CurrentPage = .Pages(.Value)
    End With
End Property

Private Sub TabCtl87_Change()

    Select Case Me.CurrentPage.Name
        Case "pg0"
            Me.sfm.SourceObject = "frm_engineerinput"
        Case "pg1"
            Me.sfm.SourceObject = "frm_visualinspectioninput"
        Case "pg2"
            Me.sfm.SourceObject = "frm_labtestinput"
[COLOR="Green"]        ' ...[/COLOR]
    End Select

End Sub

I also like to expose the CurrentPage as a property so I don't need to do this code...
Code:
TabCtl87.Pages.Item(TabCtl87.Value).Name

hth
Mark

I tried your code like this:
Code:
Property Get CurrentPage() As Access.Page
    With Me.TabCtl87
        Set CurrentPage = .Pages(.Value)
    End With
End Property

Private Sub TabCtl87_Change()

    Select Case Me.CurrentPage.Name
        Case "pg0"
            Me.sfm.SourceObject = "frm_engineerinput"
        Case "pg1"
            Me.sfm.SourceObject = "frm_visualinspectioninput"
        Case "pg2"
            Me.sfm.SourceObject = "frm_labtestinput"
        Case "pg2"
            Me.sfm.SourceObject = "frm_newinput"
        Case "pg2"
            Me.sfm.SourceObject = "frm_newuserinput"
        Case "pg2"
            Me.sfm.SourceObject = "frm_userprofile"
        Case "pg2"
            Me.sfm.SourceObject = "frm_reportcenter"
        
    End Select

End Sub

but I get a compile error: Method or data member not found and it highlights the first .sfm
 

MarkK

bit cruncher
Local time
Today, 07:30
Joined
Mar 17, 2004
Messages
8,181
Yes of course. This code requires that your form object contain a subform control called sfm.
Mark
 

psyc0tic1

Access Moron
Local time
Today, 09:30
Joined
Jul 10, 2017
Messages
360
Yes of course. This code requires that your form object contain a subform control called sfm.
Mark

Okay... so what am I doing wrong? I changed the .sfm parts to the names of the control on the tabs like this:
Code:
Select Case Me.CurrentPage.Name
        Case "pg0"
            Me.NewRecordInputForm.SourceObject = "frm_engineerinput"
        Case "pg1"
            Me.VisInputForm.SourceObject = "frm_visualinspectioninput"
        Case "pg2"
            Me.LabInputForm.SourceObject = "frm_labtestinput"
        Case "pg2"
            Me.NewPartForm.SourceObject = "frm_newinput"
        Case "pg2"
            Me.NewUserForm.SourceObject = "frm_newuserinput"
        Case "pg2"
            Me.UserProfileForm.SourceObject = "frm_userprofile"
        Case "pg2"
            Me.ReportCenterForm.SourceObject = "frm_reportcenter"
        
    End Select

but I get the same error except it highlights the first .SourceObject

Are the names incorrect? The aren't called Page1, Page2 etc.
 

MarkK

bit cruncher
Local time
Today, 07:30
Joined
Mar 17, 2004
Messages
8,181
My recommendation was that you only use one subform control. Remove it from the tab control and just use the tabs like a button bar to change out the subforms in that single control. This makes your form appear to have many subforms, but in fact there is only ever one at a time, and so it makes it wicked fast.

But if you use multiple subform controls, as the code you posted does, again, you need to ensure that those objects exist on your form. Is there a subform control called 'NewRecordInputForm' on your form, for instance? If not, then obviously when you refer to the SourceObject property of a non-existent control, the reference will fail.
hth
Mark
 

MarkK

bit cruncher
Local time
Today, 07:30
Joined
Mar 17, 2004
Messages
8,181
Also note the repetition of...
Code:
    Case "pg2"
...in the code you posted. You'll need...
Code:
    Case "pg3"
    Case "pg4"
...and so on.
Mark
 

psyc0tic1

Access Moron
Local time
Today, 09:30
Joined
Jul 10, 2017
Messages
360
My recommendation was that you only use one subform control. Remove it from the tab control and just use the tabs like a button bar to change out the subforms in that single control. This makes your form appear to have many subforms, but in fact there is only ever one at a time, and so it makes it wicked fast.

But if you use multiple subform controls, as the code you posted does, again, you need to ensure that those objects exist on your form. Is there a subform control called 'NewRecordInputForm' on your form, for instance? If not, then obviously when you refer to the SourceObject property of a non-existent control, the reference will fail.
hth
Mark

My mistake about the pg2 repeating.

Now... I guess I am not understanding what sub form control you are talking about.

My tab control tabs all have different forms on the pages with different record sources... none of them are linked with child fields except for one of the forms has sub forms on it that are linked that way.

Just dealing with the first one... the form on that tab is frm_engineerinput... the page name it is on is called NewRecordInputForm which is page index zero.

On that frm_engineerinput there are 6 fields and a command button.

To use the above code... am I supposed to blank out the source object on the data tab of the properties for that form?

When you say use the source object on the sub form... there is no sub form... it is just a form and what should the source object be? One of the fields? I do not understand.

Right now the source object in the properties for the form on page name NewRecordInputForm, page index 0 is frm_engineerinput
 

psyc0tic1

Access Moron
Local time
Today, 09:30
Joined
Jul 10, 2017
Messages
360
Here is a screenshot of the first tab and the form that is on it... what would be the subform control to use as the source object?
 

Attachments

  • Capture.jpg
    Capture.jpg
    103.7 KB · Views: 320

MarkK

bit cruncher
Local time
Today, 07:30
Joined
Mar 17, 2004
Messages
8,181
My 2c is ignore my advice. I think it has done more to confuse you than to help you. I think you were closer to solving this in a reasonably good way before I chimed in. :eek:
hth
Mark
 

isladogs

MVP / VIP
Local time
Today, 15:30
Joined
Jan 14, 2017
Messages
18,236
My 2c is ignore my advice. I think it has done more to confuse you than to help you. I think you were closer to solving this in a reasonably good way before I chimed in. :eek:
hth
Mark

LOL :D
Of course taken literally, you should ignore the advice to ignore the advice which will leave you ... well me anyway .... totally confused
 

psyc0tic1

Access Moron
Local time
Today, 09:30
Joined
Jul 10, 2017
Messages
360
My 2c is ignore my advice. I think it has done more to confuse you than to help you. I think you were closer to solving this in a reasonably good way before I chimed in. :eek:
hth
Mark

Please don't give up on me now!

Advice to ignore advice taken and ignored :D
 
Last edited:

Users who are viewing this thread

Top Bottom