Access Control over another tab (1 Viewer)

khurram7x

Registered User.
Local time
Tomorrow, 03:43
Joined
Mar 4, 2015
Messages
226
Hi,


I've form with a sub form. Sub form has two tabs. lblFName1 is a control on tab1, while lblFName2 is a control tab2.



Now I know you don't need to use the tab name while accessing the control, but here first line of code works fine...

Me.NavigationSubform.Form.lblFName1.Caption = "Please!!!"


Second line of code, which is a control on a tab which is not in forcus fails. Code is as...

Me.NavigationSubform.Form.lblFName2.Caption = "Help!!!"


I get an error: 2465 - Application defined or object defined error.

Why am i getting this please, and how to solve this??


Regards,
K
 

missinglinq

AWF VIP
Local time
Today, 18:43
Joined
Jun 20, 2003
Messages
6,423
Reproducing your scenario, assuming that your code is in your Main Form's code module...Cannot reproduce your problem! Would double-check the name of your second Tab's Label, to make sure that it is actually named lblFName2, since the Access Gnomes apparently can't find a Label with that name.

Of course, this negs the question of why you want to edit the caption of these LAbels on the fly in this manner.

Can you post the exact code (entire event) that you're using?

Linq ;0)>
 

static

Registered User.
Local time
Today, 23:43
Joined
Nov 2, 2015
Messages
823
Subforms can only contain one form. If you have 2 tabs that switch between Form1 and Form2, if you've set it to Form1 you can't refer to Form2.
 

missinglinq

AWF VIP
Local time
Today, 18:43
Joined
Jun 20, 2003
Messages
6,423
There's only one Subform...NavigationSubform. While it is common to place Subforms on the Pages of a Tabbed Control...the post doesn't refer to two Tabs with a Subform on each one.

Linq ;0)>
 

khurram7x

Registered User.
Local time
Tomorrow, 03:43
Joined
Mar 4, 2015
Messages
226
Subforms can only contain one form. If you have 2 tabs that switch between Form1 and Form2, if you've set it to Form1 you can't refer to Form2.
Thanks. Is it possible please to refer to Tab2 somehow in code and then refer to the control on the form on Tab2?


Actually the code above I was using for testing. In production, I've two tabs on a form each having a sub-form.

My requirement is, when I fill SignedOut time field in the form on Attendance tab it automatically fills the EndTime against the form on WPAllocation tab.


I'm uploading the screenshots of both tabs and sharing the link, if it helps please:



https://drive.google.com/open?id=15MTzVgUeVPqQQQ9RXRUNWUyiX2qVXUYc


Thanks,
K
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:43
Joined
Feb 19, 2002
Messages
43,346
No, not on a Navigation form. This form style specifically uses a SINGLE subform control which can contain only one subform at a time. That means that you can only refer to the currently loaded subform.

If you need to refer to multiple subforms, you need to ditch the Navigation form and switch to using a main form with a tab control. That will allow you to have multiple subforms loaded at once if you need to.

Keep in mind that the Navigation form works the way it does for the sake of efficiency. It will make the form "lighter" and load faster if only a single subform is ever loaded at one time.
 

Wayne

Crazy Canuck
Local time
Today, 18:43
Joined
Nov 4, 2012
Messages
176
If you are referring to the tab controls page captions, you would use:

Me.Page1.Caption = "Whatever"
Me.Page2.Caption = "Something Else"

You can use a field's value for the cation name as well.

Me.Page1.Caption = Me.YourFieldName

Not sure if this is what you're looking for, but hope it helps.

Wayne
 

khurram7x

Registered User.
Local time
Tomorrow, 03:43
Joined
Mar 4, 2015
Messages
226
...s, you need to ditch the Navigation form and switch to using a main form with a tab control. That will allow you to have multiple subforms loaded at once if you need to.
Ok I'm trying a sample Main form with Tab control but i still get same error.


By the way, by main form i meant that i created a Form Design and put a Tab control on it. Let me know if i'm wrong please?
 

Minty

AWF VIP
Local time
Today, 23:43
Joined
Jul 26, 2013
Messages
10,371
A tab on a form is NOT a sub form, merely an extension of the forms area. You simply refer to controls on it the same as any other control ;

Me.YourControlName

If you have Sub forms on tabs they are referred to in exactly the same way as any other subform. Bookmark this page for the correct syntax http://access.mvps.org/access/forms/frm0031.htm

As already noted by others, this all goes out the window if you use the inbuilt navigation form as it dynamically loads the forms as subforms.
 

isladogs

MVP / VIP
Local time
Today, 23:43
Joined
Jan 14, 2017
Messages
18,246
Subforms can only contain one form. If you have 2 tabs that switch between Form1 and Form2, if you've set it to Form1 you can't refer to Form2.

@static
Were you referring to a specific type of form here?
Subforms can certainly contain more than one form e.g. for example, the subform on the left in the screenshot contains 3 'sub-subforms' (though one of them isn't visible in this screenshot)

 

Attachments

  • Capture.PNG
    Capture.PNG
    53.2 KB · Views: 248

static

Registered User.
Local time
Today, 23:43
Joined
Nov 2, 2015
Messages
823
A subform control can only contain one form. A form can contain multiple subform controls.
 

isladogs

MVP / VIP
Local time
Today, 23:43
Joined
Jan 14, 2017
Messages
18,246
A subform control can only contain one form. A form can contain multiple subform controls.

Ah - that's a different matter.
Any form (or report) control can of course only contain one item
 

isladogs

MVP / VIP
Local time
Today, 23:43
Joined
Jan 14, 2017
Messages
18,246
LOL:)

static has just replied to a thread you have subscribed to entitled - Access Control over another tab - in the Modules & VBA forum of Access World Forums.

This thread is located at:
https://www.access-programmers.co.uk/forums/showthread.php?t=299927&goto=newpost

Here is the message that has just been posted:
***************
How is it a different matter? It's exactly what I said above.
***************

Ah ... but it wasn't ... was it?
That's the trouble with instant notifications.
You can delete the post but the email has already been sent! :D
 

static

Registered User.
Local time
Today, 23:43
Joined
Nov 2, 2015
Messages
823
I deleted the post because I got sick of your pedantry in the other thread.

You seem to be finding it funny. I just find it boring and slightly annoying.
 

isladogs

MVP / VIP
Local time
Today, 23:43
Joined
Jan 14, 2017
Messages
18,246
I wasn't being at all pedantic in the other thread.

I was asking you to justify a statement you had made. However, you made no attempt to do, instead resorting to petty insults such as 'trolling'. My attempts at humour may not be to your taste but to my mind its better than responding in kind

Similarly I was asking you for clarification in this thread.
What you originally wrote was incorrect.
I'm sure it wasn't what you meant & gave you the opportunity to clarify it.

I'm the first to recognise that I also make mistakes in my posts & I get picked up on them when I do.
As far as I'm concerned that's absolutely fine providing its done politely.

Shall we let the matter drop at this point?
 

isladogs

MVP / VIP
Local time
Today, 23:43
Joined
Jan 14, 2017
Messages
18,246
Your attempt at humour or just being pedantic?
 

static

Registered User.
Local time
Today, 23:43
Joined
Nov 2, 2015
Messages
823
No, I haven't lowered myself to your level yet. LOL It was a genuine question.

I can't say the problem is solved because I don't know what the problem was in the first place.

You have a problem with my writing style. (Or something?) Well that's not going to change.

So, we just vow to ignore each other? Is there a block option on this site?
 

Wayne

Crazy Canuck
Local time
Today, 18:43
Joined
Nov 4, 2012
Messages
176
Didn't your Mama tell you to play nice with the kid next door?
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 23:43
Joined
Jul 9, 2003
Messages
16,285
Didn't your Mama tell you to play nice with the kid next door?

My dad always told me never to close any doors.. Meaning (I think) never allow a situation develops between yourself and someone else, where you find you can't go back to them sometime in the future. Always seamed like good advice to me!
 

Users who are viewing this thread

Top Bottom