How to pass name of the tab into the query in access 2007

VPK_Access

Registered User.
Local time
Today, 08:35
Joined
May 15, 2011
Messages
36
Hi,

I am new in Access 2007.

I have created a form which has multiple tabs created. I one of the tab I have created a button, when clicked it executs a report, based on the value of a field in the tab.(currently I have put a default value for this field, which I want to parameterise).

Now this is my issue..... I want to execute the report based on the value of the tab name, so that I do not have to create multiple reports and queries for each tab.

Could you please help me in proving a way to get the tab name and how can I can pass the tab name into the query as an argument.

Thanks for any help in advance
 
Surprisingly, the name of the tab is not needed at all.
Just use the name of the form and subform (if there is one) together with the control name.
Do it the same way as a form without tabs.
 
Thanks for the reply. I tried using the below as a arugument to the query. Here OpeningForm is my form name, TabCtl0 is my control tab name where different tabs are defined. In my query if a field value is equal to the below value return values to the drop down list is what I have done.

[Forms]![OpeningForm]![TabCtl0].[Name]

Though the query is not giving an error, it is not giving any output value to the drop down list. What am I doing wrong?
 
As Jeanette said, the name of the tab is not part of the form reference. Try

[Forms]![OpeningForm].[Name]

By the way, "Name" isn't a good idea as an object name, as it's a reserved word:

http://allenbrowne.com/AppIssueBadWord.html
 
I think I didnt explain my issue clearly. I have the main form (Opening form), which has multiple tabs in it (Tabs are name say A1, A2, A3..). When I click on each tab there is a drop down displayed(I have the drop down value retrieving value based on a query).

Now what I want is that when a user clicks tab A1, execute the query where a field in the query is equal to A2; similarly when a user clicks tab A2, execute the query where a field in the query is equal to A2..... so that the drop down in each tab changes as and when the user clicks the tab.

Now by [Forms]![OpeningForm]![TabCtl0].[Name] what I thought of retrieving is that name of the tabs(A1, A2...). I wanted the above to pass the name of the tab which I am clicking to the query, hence used the [Forms]![OpeningForm]![TabCtl0].[Name].

Obviously I am not doing it right. Could you please let me know how to get the tab name (what each user clicks) and what is the syntax to be used in the query.

Thanks in advance.
 
Tabs (on a form) are simply a way of giving you a greater area of form real-estate to play with and a method of better organising your controls on said form. Consequently any control on the form/tab is simply referenced, in your query as Forms!FormName!ControlName it doesn't matter which tab it's on for this purpose.

Perhaps you need to re-think the logic behind what it is you are trying to achieve.

If I've understood you correctly. You have a combo box on each tab that you wish to sync with a text box on that same tab, is this correct?
 
I have a combo box on each tab that I want to sync based on name of the tab. I just though either of the below methods can be used.(please correct me if I am wrong)
1) To assign the name of the tab clicked to a text box on the main form.So that I can then use then pass the text box value to the query. If this is righ what is the systax to assign value to a text box.
2) Or How can I directly pass the name of the Tab click to the query, so that the combo box in the tab clicked retrievs value based on the tab name. If so what is teh synatx.

I am sorry if I am not using the right method as I am new to Access.
 
You could use the following in your Tab Control's On Change event;
Code:
Me.YourTxtBox = Me.YOurTabControl.Value
Remember that the tabs are zero indexed so that tab one will return a value of zero and tab two a value of 1, etc.
 
Thanks a lot...that works. You are just rocking.

I changed what you said to the below. It is assigning the name of the tab to the textfield and I am then sending the text field value to my query

Forms!OpeningForm!mytextbox = Forms!OpeningForm!TabCtl0.Pages(Forms!OpeningForm!TabCtl0).Name

You comment on to include it in OnChange event is what helped me.

Thanks a ton!
 
I think this is correct, without testing it.

Tab names are a bit circular

Tabs are accessed by ordinal number. tab0, tab1 etc etc
you can directly access a tab, by its name tab("sometab")

but you can only get the name, if you know the tab number (I think) - although maybe there is syntax to retrieve the active tab?

-----
but you don't need the tab anyway. all controls on a tab, are just part of the form - and have to be unique names

so you can only have one combobox1 - on your form - irrespective of the tab it is on.

so I think we are all struggling to understand what you are trying to achieve.
 

Users who are viewing this thread

Back
Top Bottom