Passing values from report to form tabs

newbie87

Registered User.
Local time
Today, 07:17
Joined
Sep 9, 2011
Messages
43
Hi All,

I have this report which allows me to see all data in all of my tables

On the report next to each row of information I have a view button which posts the data on to my main form which is made up of the tab controls.

The problem I am having is when I click the view button, I only want to post the data on tab 1, but it posts on tabs 1 and 2

I did add this code in but it came up with “Run time error ‘438’ Object doesn’t support this property method
Forms!form1!tab1.Name = Me.Name

Anybody got any idea’s, many thanks for your help in advance.
 
I believe you are referencing the control incorrectly. Try something more like this:

Code:
[Forms]![YourFormName].TabControlName.Pages.Item("TabName").YourCodeHere
 
Hi,

Thanks for your response.
this still doesnt work, i still get the following error “Run time error ‘438’ Object doesn’t support this property method
I have based my new reference on the reference you have suggest, this is below.

"[Forms]![YourFormName].TabControlName.Pages.Item("TabName").YourCodeHere"

[Forms]![frmTabs].TabPage.Pages.Item("Revision1").Name = Me.Name

Many thanks.
 
Your form is called frmTabs? Is that a subform?

Are you trying to change the text displayed at the top of the tab? Try changing the caption property instead.

Also, when posting code, encapsulate the code with [ code] and [ /code], minuses the spaces. If you highlight the code, there is a button that will do this for you if you don't use the quick reply like I do.

edit- if you still can't get it, just try to upload your db, I'm sure I can figure it out.

edit- I just read your first post again (or maybe for the first time!) and I am confused about what your trying to do. You say that you have a button on a form where On Click, you want "the data" to go to your form. From what you said and what your code says, you want the name of the button to be put as the name of the tab. This doesn't make sense to me. Nor does using a report to influence what a form says. Usually its the other way around. I have never asked for user input on a report, but maybe that is just my preference.
 
Last edited:
Hi speakers_86,

My aim is to allow the user to view a history report of their current details, then when the user clicks the view button, this passes all of their data to the relevent text fields on the form, where they can then edit/update and add further details.

The frmTabs is not a subform its just a seperate form, my report is called History, once i click view on this report, the data should be sent to the frmTabs form, which has the tab control on it (TabPage). Tab1 is called Revision1, (for the name and the caption property), and Tab2 is called Revision2

this is the code for my view button:

Code:
Private Sub View_Click()

DoCmd.OpenForm "tabs"
Forms!frmTabs.TabPage.Pages.Item("Revision1").Name = Me.Name
Many thanks for the help
 
Based on your code, you are trying to rename the tab to be the name of the combo box in the click event. Is this right? Can you upload your db?
 
Hey,

I've just done a quick mock up for what im working on, its attached, the buttons on the form don't work, its jus ta visual so you can see what I am doing.
the history report shows the data from the table, which i need to pass to the form using the reference that im having trouble with
Code:
Forms!Tabs.TabPage.Pages.Item("Revision1").Name = Me.Name
Forms!Tabs.TabPage.Pages.Item("Revision1").Address = Me.Address
Again, my aim is to allow the user to view a history report of their current details, then when the user clicks the view button, this passes all of their data to the relevent text fields on the form, where they can then edit/update and add further details.

Many thanks
 

Attachments

My aim is to allow the user to view a history report of their current details, then when the user clicks the view button, this passes all of their data to the relevent text fields on the form, where they can then edit/update and add further details.
The OpenForm command has a WHERE argument which allows you to filter the form based on a field or multiple fields. The syntax is something like this:
Code:
DoCmd.OpenForm "tabs", , , "[[COLOR=Red]ID on form[/COLOR]] = " & Me![[COLOR=Red]ID field from report[/COLOR]]
You can use that to open your form and it will open with that customer's details. Amend the bits in red.

If you want to change the caption of a tab, use the Caption property:
Code:
Forms!frmTabs.TabControl.Caption = Me.Name
 
The first issue I see is that you have a field called "Name". Name is reserved word, because Access uses that name itself.

But this may actually highlight your other issue though.

Forms!Tabs.TabPage.Pages.Item("Revision1").Name = Me.Name
The .Name at the end is referring to the name of the TAB, not the field that you call "Name". This is why I asked a few times if you were trying to rename the tab. I kinda figured...

Maybe this is what you need, assuming you rename your field as "CustomerField".
Code:
[forms]![frmTabs]![CustomerName] = me.CustomerName


edit - I also recommend looking into naming conventions. Objects should be named descriptively, not like your query called Select *., or the table called Details.
 
Hi,

Thank you both for your input, I wil ltry to work on these tomorrow.

speaker_87, I know the nbaming conventions etc are rubbish haha, but I just created a mock up of the project I'm working on, everything is named correctly etc in the original, many thanks for the input though

[forms]![frmTabs]![CustomerName] = me.CustomerName

this would pass the data to the form, but it populates both tabs, which is why i need to reference the tab1 and tab1 seperatley if that makes sense?

vbaInet, I shall try these out and let you know how I get on with it

DoCmd.OpenForm "tabs", , , "[ID on form] = " & Me![ID field from report]
 
this would pass the data to the form, but it populates both tabs, which is why i need to reference the tab1 and tab1 seperatley if that makes sense?

Yes, I forgot about that part. Still yet, you do not need to reference the actual tab, because the tab is not like a subform. The tab is just to make it look nice, and has no bearing on how you reference the controls. What I brought up earlier about referencing the control was only because I thought you were trying to rename the caption for the tab.

How does that help you? It seems both of your controls have the same name. Just change the name of one of the controls.
 

Users who are viewing this thread

Back
Top Bottom