473,325 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Finding the Caption on a form

489 256MB
I have a form open (form1) and that form opens another form (form2), in form2 I want to find the tab caption on form1 but can't figure out the code. Any help is appreciated.
Thanks
Jan 21 '16 #1

✓ answered by jforbes

Haha, don't even worry about it. We are getting it.

I think I over complicated it for you then. I was trying to get the Caption of the currently selected Tab. So, half of the code can be removed and replaced by a hard coded 3; 3 because it is a 0 based array and you want the fourth Tab. More like this then:
Expand|Select|Wrap|Line Numbers
  1. Forms("editmasterWAnnual").Controls("tabCtl196").Pages(3).Caption

10 2028
jforbes
1,107 Expert 1GB
This is one, easy way:
Expand|Select|Wrap|Line Numbers
  1. forms("Formname").Caption
It wont work for subForms or Forms that aren't loaded.
Jan 21 '16 #2
CD Tom
489 256MB
Ok that gives me the caption of the form but how do I get the caption of one of the tabs on that form. I have four tabs WUMatch, WBMatch etc I want to find out the caption for one of those.
Jan 21 '16 #3
jforbes
1,107 Expert 1GB
Ahh, I missed that particular. Sorry about that. This might be more like what you want:
Expand|Select|Wrap|Line Numbers
  1. Forms("FormName").Controls("TabCtrlName").Pages(Forms("FormName").Controls("TabCtrlName").value).Caption
Jan 21 '16 #4
CD Tom
489 256MB
ok I get an error here's the code
Expand|Select|Wrap|Line Numbers
  1. VMCaption = Forms(editmasterWannual).Controls(BPMatch).Pages(Forms(editmasterWannual).Value).Caption
What am I doing wrong?
I've tried it with the " around the form name with the same error.
Thanks for your help with this
Jan 21 '16 #5
jforbes
1,107 Expert 1GB
If BPMatch is the Tab Control's Name and the Form Name is editmasterWannual, then I think this should do it. ...I haven't tested it

Expand|Select|Wrap|Line Numbers
  1. VMCaption  = Forms("editmasterWannual").Controls("BPMatch").Pages(Forms("editmasterWannual").Controls("BPMatch").Value).Caption
Expand|Select|Wrap|Line Numbers
  1. Forms("editmasterWannual").Controls("BPMatch").Value
should get the ordinal value of the current Tab and the rest gets the caption once we have the currently selected tab.
Jan 21 '16 #6
CD Tom
489 256MB
I still get the error 438 "Object doesn't support this property or method
Expand|Select|Wrap|Line Numbers
  1. VMCaption = Forms("editmasterWannual").Controls("BPMatch").Pages(Forms("editmasterWannual").Controls("bpMatch").Value).Caption
this is the code but don't know what's wrong, could I be missing a reference?
I have to run for a couple of hours will try your answer when I get back.
Thanks again
Jan 21 '16 #7
jforbes
1,107 Expert 1GB
Well, that's a drag. I don't think there's a reference for this as they are in the Access Namespace, according to the Object Browser(F2).

https://msdn.microsoft.com/en-us/lib...ffice.12).aspx
https://msdn.microsoft.com/EN-US/lib.../ff835052.aspx

I figured it out by using the Immediate Window in the VBA Editor and MSDN Documentation, linked above. You should be able to also use the Immediate Window to find out what is going on. I would try entering some of the following lines into the Immediate Window to hopefully see where the error is occurring:
Expand|Select|Wrap|Line Numbers
  1. ?Forms("editmasterWannual").Name
  2. ?Forms("editmasterWannual").Controls.Count
  3. ?Forms("editmasterWannual").Controls("BPMatch").Name
  4. ?Forms("editmasterWannual").Controls("BPMatch").Value
  5. ?Forms("editmasterWannual").Controls("BPMatch").Pages.Count
Jan 21 '16 #8
CD Tom
489 256MB
I get the 438 error on the last two statements. Usually when I put in the controls and the . it gives me a drop down to select from, but when I put in the ("BPMatch") and the . I get no dropdown. Although when I entered the .name it gave me the Name BPMatch.
Jan 21 '16 #9
CD Tom
489 256MB
Ok now I feel real bad, I gave you some wrong information. Hopefully you will not cut me off from your expertise. I gave you the wrong Control name the code that works kind of is
Expand|Select|Wrap|Line Numbers
  1. v6 = Forms("editmasterWAnnual").Controls("tabCtl196").Pages(Forms("editmasterWannual").Controls("tabctl196").Value).Caption
In the tabctl196 there are 7 tabs I want to find what is in the tab name BPMatch The above code gives me what in the first tab. the tab name BPMatch is like the 4th one over.
Jan 21 '16 #10
jforbes
1,107 Expert 1GB
Haha, don't even worry about it. We are getting it.

I think I over complicated it for you then. I was trying to get the Caption of the currently selected Tab. So, half of the code can be removed and replaced by a hard coded 3; 3 because it is a 0 based array and you want the fourth Tab. More like this then:
Expand|Select|Wrap|Line Numbers
  1. Forms("editmasterWAnnual").Controls("tabCtl196").Pages(3).Caption
Jan 21 '16 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Paul T. Rong | last post by:
Hello, Often when I open one form, and (without closing it) open the form in its design view, then all the caption value of the controls in this form remained there in form's design view that is...
7
by: Stu | last post by:
Hi, I have a combobox who's values change the recordsource of the form. Within this form, there is a subform, whos records also need to change pending the value in the combobox. I am able to get...
1
by: sc | last post by:
From my codebehind, I am trying to get an object reference to the current form, so I can perform a FindControl and work with one of the child controls. My problem is that I never know the name...
1
by: Karl Prosser | last post by:
i have various usercontrols that get dynamically into a page my usercontrol has html Input fields, and from javascript i need to access them, however to access them i need to know the form.....
1
by: MuZZy | last post by:
Hi, I'm trying to find a way to find out a form menu height/color as i think it changes depending on various Windows settings. I need to create a form of height/color of form menu so that i can...
14
by: kelvin.jones | last post by:
Hi, if I had the ID of an input element, how can I find the input's FORM in javascript? Basically, given a input's dom id, I want to insert something in the onSubmit of the Form that that input...
4
by: bg_ie | last post by:
Hi, I have an Access document which I've been asked to debug and update a little. The problem is that i can't find where one of the Forms is being called from. In other words, I can't navigate...
7
by: dkohel | last post by:
I have a form that returns 100 items. All of the items have have a different value in their Category field. EXAMPLE: ---------------- A B C How can I change the value of the caption in...
3
beacon
by: beacon | last post by:
Hi everybody, I'm using Access 2010, but the format for the database is .mdb because I'm not ready to fully convert it to Access 2010 and the .accdb format. I've been reading up on how to...
1
by: DenverBigDad | last post by:
I have an access database that I am developing for use each day. I am a relatively inexperienced vba user, so I am using/reusing a lot of code that I have developed for specific tasks, learning new...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.