?
Solved

Cant refer to control on subform from another subform. Both subforms are on the main form.

Posted on 2012-09-21
23
Medium Priority
?
669 Views
Last Modified: 2012-09-21
Hello,

I have a main form, "frm_Switchboard" and two subforms on it: "frm_BU_Profile_Selection" and "frm_Profile". There are other subforms in other tabs as well, but these are the two I am concerned about here.

On the main form I have a tab control, and the two subforms are each in their own tab. However, I have read from many sources that assure me that the tab control has no impact on how I reference the controls.

I am trying to place the value from this textbox,  "frm_BU_Profile_Selection!txtSelected_BU_Name" into the following textbox, "frm_Profile!txtBU_Name", but all of the syntax that I try, fails. Sometimes I get the "#Name?" and sometimes I just get a blank field in frm_Profile!txtBU_Name, depending on the syntax.

Can you please tell me what the correct syntax is for making this reference?

Thank you!
Riverwalk
0
Comment
Question by:RiverWalk
  • 14
  • 5
  • 4
23 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38422788
where did you placed the codes?

see this for reference

http://access.mvps.org/access/forms/frm0031.htm
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 400 total points
ID: 38422792
It depends on where you're running the procedure from:

'From the Main form
Me.frm_Profile.Form!txtBU_Name = Me.frm_BU_Profile_Selection.Form!txtSelected_BU_Name

'From the subform (frm_Profile)
Me.txtBU_Name = Parent.frm_BU_Profile_Selection.Form!txtSelected_BU_Name

'From the subform (frm_BU_Profile_Selection)
Parent.frm_Profile.Form!txtBU_Name = Me.txtSelected_BU_Name

Open in new window

0
 

Author Comment

by:RiverWalk
ID: 38422798
This might help someone help me... I can place a button on frm_Profile, and on the Click event, I have this code:

Parent![frm_BU_Profile_Selection]![txtSelectedBU_Name1]

when I click the button, the value from txtSelectedBU_Name1 displays correctly in the message box. But when I use the above reference in the ControlSource of frm_Profile!txtBU_Name, I get nothing. Just a blank empty field.

Thank you,
Riverwalk
0
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

 

Author Comment

by:RiverWalk
ID: 38422804
Thanks IrogSinta.. Our posts just now crossed. I will try your suggestions and report back.

Thank you!
Riverwalk
0
 

Author Comment

by:RiverWalk
ID: 38422820
I am trying to do this from frm_Profile (one of the subforms) so I used this one...

'From the subform (frm_Profile)
Me.txtBU_Name = Parent.frm_BU_Profile_Selection.Form!txtSelected_BU_Name

After doing that, I get "#Error" in frm_Profile!txtBU_Name.  I placed your suggested line, in the Control Source of frm_Profile!txtBU_Name.

Any ideas?

Thank you,
Riverwalk
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38422843
RiverWalk,

you should be using the name of the subform control... instead of the subform name

did you look at the link i posted above
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38422852
The code I gave you was for use within the form's code module.  If you are wanting to use an expression in a control, just start from the equal "=" sign.
= Parent.frm_BU_Profile_Selection.Form!txtSelected_BU_Name
0
 

Author Comment

by:RiverWalk
ID: 38422891
IrogSinta,

When I use "= Parent.frm_BU_Profile_Selection.Form!txtSelected_BU_Name" as the Control Source, I get "#Error"...


capricorn1,

Yes, thank you. I was looking at that link before I got on EE. I believe I am using the name of the subform control. I have looked at the properties and the Name and Source Object are the same,  they are both, "frm_BU_Profile_Selection". Is this what you are referring to?

Thanks,
Riverwalk
0
 

Author Comment

by:RiverWalk
ID: 38422932
FYI:  Here is exactly what I used as a Control Source before I moved over to the tabbed control approach. When I was using this below refernce, none of my forms were inside another form. They were each their won main form. But now I have moved them all into tabs on a main form, called frm_Switchboard. That's the only change.

=[Forms]![frm_BU_Profile_Selection]![txtSelectedBU_Name1]
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38422964
Looks like the name of your textbox is different. It has a 1 at the end.
0
 

Author Comment

by:RiverWalk
ID: 38422965
If I use the Expression Builder, from the Control Source field, and navigate top down through the Switchboard form down to txtSelectedBU_Name1, I get the below expression.

I figured that if I let Access build the reference that it would work, but the below reference does not work. I don't get an error, I just get an empty field, i.e. txtBU_Name is blank when I open my forms and make the necessary selections.

THIS IS BUILT FROM THE EXPRESSION BUILDER, BUT DOES NOT WORK
Forms![frm_Switchboard]![frm_BU_Profile_Selection].Form![txtSelectedBU_Name1]

Thank you,
Riverwalk
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38422982
upload a copy of your db
0
 

Author Comment

by:RiverWalk
ID: 38422985
IrogSinta,

Good catch, but I have corrected that, and I still get "#Error".  

I am using this...

=[Parent].[frm_BU_Profile_Selection].[Form]![txtSelected_BU_Name1]


Thanks,
Riverwalk
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38423014
Does txtSelected_BU_Name1 have an expression in its Control Source? If not, then as Cap1 said, upload a copy.  I won't be able to see it but Cap1 will.
0
 

Author Comment

by:RiverWalk
ID: 38423033
No, txtSelected_BU_Name1 does not have an expression in the Control Source. It's control source is blank.

To upload a copy, I will have to delet a LOT of reocords, and the database will not work properly with the records deleted, but it will likely be helpful for you or Cap1 to see it anyway. I will upload in just a moment.

THanks,
Riverwalk
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38423042
just include a couple of DUMMY records
0
 

Author Comment

by:RiverWalk
ID: 38423084
Ok, here are the steps.

1. From Main Menu, click on BU Selection button.
2. Click the Campus, Houston
3. Click Segment, then SPU, and then the last listbox selection that shows several fields.
4. One you do setp 3. you will see the text box populate at the bottom of the form.
5. Now click on the BU Information button on the right side.

6.This form that opens should be showing the selected BU. The text box that populated on the previous screen, denoted in step 4.

Let me know if you have any questions.

Thank you!
Riverwalk
0
 

Author Comment

by:RiverWalk
ID: 38423089
Not sure if the attachement made it. I am trying again.
0
 

Author Comment

by:RiverWalk
ID: 38423128
When I try to attach it just clocks for a long time. The file is not very big. Not sure what is going on. I zipped it this time, now it is very small.
0
 

Author Comment

by:RiverWalk
ID: 38423134
Having a heck of a time. Trying FireFox now. IE is killing me.
CRM---Copy.zip
0
 

Author Comment

by:RiverWalk
ID: 38423138
Ok, great! There it is. I so very greatly appreciate all of your help!

Riverwalk
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1600 total points
ID: 38423532
RiverWalk,

* remove the entry in the Control Source of txtBU_Name

* in the click event of lstBU
add this line

Form_frm_Profile!txtBU_Name = Me.lstBU.Column(2)

or you can also use this

Me.Parent!frm_Profile.Form!txtBU_Name = Me.lstBU.Column(2)

both will give the same result
0
 

Author Comment

by:RiverWalk
ID: 38423614
Awesome! Thank you! I don't know if there would be an Experts Exchange without you Capricorn1. I am very grateful. This has been killing me for hours. I don't know why I got so fixated on making it work the way it used to work.

I still don't understand why it can't be made to work the way it did before from the Control Source. Do you?  I'm not still looking for a Control Source based solution, just wondering if you know why it won't work that way anymore.

Thank you!
Riverwalk
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question