Getting data from another form to display in header on main form.

louisa

Registered User.
Local time
Today, 19:40
Joined
Jan 27, 2010
Messages
262
Hi all,
Im sure this is easily done but i keep getting an error.
I have a database with many tabs, the first tab is contacts, second is security.
In the security tab i have a field called account number, on the contacts page in the header i have the name of the customer displayed in big writing, i use the following to get this ="Company: " & [CompanyName] i now want to be displayed next to that, the account number, which is on the other tab and this field is in a seperate table. I have tried along the lines of =Form!MyFormName!MyFieldName but i get the #name?
Can anyone advise?
Many thanks
Louisa
 
as you've seen, you can reference another field on the same form by closing the name with brackets. But it doesn't work for labels.

I don't believe tabs matter, but I could be wrong. Tabs are all part of the same form. so what's the entire control source syntax you have now?
 
Swap Form! for Forms! at the beginning of your reference.

It's important to note it's the control name you are referencing, not the field name from the table. If the control has a different name that has to be used.

Also, if the field being referenced is in a subform you will need to change it to
Code:
=Forms!MyFormName!MySubformControlName.form!MyControlName
 
I don't believe tabs matter, but I could be wrong. Tabs are all part of the same form. so what's the entire control source syntax you have now?
That's right, you don't need to reference the tab control because all the tab is for is layout.

And just fyi, we can still use:
Code:
=Forms!MyFormName!MySubformControlName!MyControlName

Without the .Form reference.
 
CBrighton Apologies, it is set to =Forms
the_net_2.0 I have tried ="Account: " & [AccountNumber] all i receive is #name?
 
Change the name of the control from AccountName to txtAccountName and refer to the control or the field name - former is preferrable.
 
The text box control (not the field on the table) is named "AccountNumber" and it is on the same form?

The fact that your original post says the field which the control uses is on a different table makes me think it is likely to be on a subform with a different recordsource or on a different form altogather.
 
My form is called "security" and the field is called "accountnumber" it isnt a subform or a label. As the control source i have entered =Forms!Security!AccountNumber all i receive is #name?
 
Hi sorry, it is on one of my tabs in the main form, but i created a new form for security and dragged the form onto the tab.
 
Sounds like a subform to me, that will have to be included in the reference.

Does the tab contain a box with rulers / scroll bars when in design view?

Example screenprint attached showing one of my forms with a tab control containing a subreport containing a tabcontrol.

:edit:

Sorry I didn't crop (dual monitor) then the forum compressed & resized it. You can still see the second set of rulers & scroll bars within my main form though.
 

Attachments

  • SubForm.jpg
    SubForm.jpg
    107.5 KB · Views: 165
Last edited:
I think you may have missed my last post -->
Change the name of the control from AccountName to txtAccountName and refer to the control or the field name - former is preferrable.
Then use this in the control source:
="Company: " & txtAccountName

That is if there's no subform.
 
Yes the tab does contain rulers and a scroll bar.
From your picture you have =[textforename] etc that is where i have my ="Company: " & [CompanyName]
Underneath you then have your tabs, that it where mine are with one as company (yours personal data) then security (yours work date) from there i just have my form but i can see you have tabs within your tabbed form, i do not have that.
 
Hi sorry, it is on one of my tabs in the main form, but i created a new form for security and dragged the form onto the tab.

This will create a subform, I just tested it.

You need to check the name of the subform object (not the form is contains, the control name) and include that in the reference.


:edit:


Click on something else in the form (something in the header for example).

The click once on something in the security form.

You should find the whole box containing the form is selected, the properties window can then be used to get the name of the subform control.

You can then reference it with: Forms!FormName!SubformControlName!ControlName
 
Attached to this post is a better screen-print showing when the subform is clicked once (when something on the main form was selected before) the properties window shows the subform control name.
 

Attachments

  • SubForm.jpg
    SubForm.jpg
    94.6 KB · Views: 204
I have done as suggested however it says the name is "security"
 
OK, the format we are after is: =Forms!FormName!SubformControlName!ControlName

You haven't given the main form name, but security is the SubFormControlName.

sub in the main form name, subform name (security) and field name in the above reference.
 
No i didnt give the main form name. Main apologies. I now have it working, thank you so much for your help and patience.
 
And just fyi, we can still use:
Code:
=Forms!MyFormName!MySubformControlName!MyControlName

Without the .Form reference.

I'd have to see proof for that, bud. ;)

I think it does matter for different versions. This program stinks sometimes.
 
I'd have to see proof for that, bud. ;)

I think it does matter for different versions. This program stinks sometimes.
Just to clarify, I'm talking about the .Form reference, not the Forms!

What version of Access have you seen this not working?
 

Users who are viewing this thread

Back
Top Bottom