I don't know how to send a link to a conversation, so I copied an earlier conversation I had with John. Perhaps this will help.
>>>>>>>>>>>>>>>>>>>>>>>>
David-
I have a question referencing Navigation forms and how to reference controls on a Navigation subform. I got my syntax to work, but I do not understand how it can work. I am on a form that is not part of a Navigation control and needing to get a value from a combo box that is on a subform of the Nav control. The syntax that worked for me does not seem like it should be able to work.
My Navigation form is frmMainNav and the subform control is named sfrmMainNav. One of the Navigation subforms is frmConfigureSampleGroupSpecs. From frmConfigureSampleGroupSpecs with a cmdButton I call a form to add new records. I'll just call it frmA. This frmA is NOT on any Navigation control.
On frmA I have a hidden text box that I use to store an ID number from one of the list boxes on frmConfigureSampleGroupSpecs. I use that ID number to filter a combo on frmA. My code for getting that ID number from frmConfigureSampleGroupSpecs worked just fine until I made that form a subform on the Navigation control. The assignment statement that worked initially was "= Forms!frmConfigureSampleGroupSpecs!cboSelectSite.column(1)". When the form was made a Navigation control subform, and the assignment code quit working, I used syntax I saw on another web site and changed the text box assignment to "=Forms!frmMainNav.sfrmMainNav.Form!cboSelectSite.Column(1)". It did not work. Then, I looked at that statement and thought, well it cant work because I am not telling Access what the name of the form is which holds the cbo whose column(1) value I want.
So, my next attempt was what I guess might be called a "fully qualified name", if that terminology is correct. So my next attempt was "=Forms!frmMainNav.sfrmMainNav.frmConfigureSampleGroupSpecs.cboSelectSite.column(1)"
Now, that made sense to me but apparently not to Access. So, I tried several others including "=Forms!frmMainNav.sfrmMainNav.Form!frmConfigureSampleGroupSpecs.cboSelectSite.column(1).
After multiple tries, and a lucky guess, this simple little syntax below worked:
=[Forms]![frmMainNav].[sfrmMainNav]![cboSelectSite].[column](1).
Can you explain to me please how this can possibly work? How is it possible that Access can know which subform this combo cboSelectSite is on? The syntax above does not tell Access which subform to look at to find the combo, but it works??
The general syntax to reference a control on a subform is:
Forms!NameOfOuterForm!NameOfSubformCONTROL.Form!NameOfControl
So, I would have thought that you need to do:
=[Forms]![frmMainNav].[sfrmMainNav].Form![cboSelectSite].[column](1)
It may work a bit differently for Navigation forms, so perhaps that's why your syntax worked. Note that the *name* of the form in the subform control is not important. You must always use the name of the subform control. The .Form should reference whatever form is inside the subform control.
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
(Paris, France)
On May 7, 2017, at 2:36 PM, david.pratt@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
I have a question referencing Navigation forms and how to reference controls on a Navigation subform. I got my syntax to work, but I do not understand how it can work. I am on a form that is not part of a Navigation control and needing to get a value from a combo box that is on a subform of the Nav control. The syntax that worked for me does not seem like it should be able to work.
My Navigation form is frmMainNav and the subform control is named sfrmMainNav. One of the Navigation subforms is frmConfigureSampleGroupSpecs. From frmConfigureSampleGroupSpecs with a cmdButton I call a form to add new records. I'll just call it frmA. This frmA is NOT on any Navigation control.
On frmA I have a hidden text box that I use to store an ID number from one of the list boxes on frmConfigureSampleGroupSpecs. I use that ID number to filter a combo on frmA. My code for getting that ID number from frmConfigureSampleGroupSpecs worked just fine until I made that form a subform on the Navigation control. The assignment statement that worked initially was "= Forms!frmConfigureSampleGroupSpecs!cboSelectSite.column(1)". When the form was made a Navigation control subform, and the assignment code quit working, I used syntax I saw on another web site and changed the text box assignment to "=Forms!frmMainNav.sfrmMainNav.Form!cboSelectSite.Column(1)". It did not work. Then, I looked at that statement and thought, well it cant work because I am not telling Access what the name of the form is which holds the cbo whose column(1) value I want.
So, my next attempt was what I guess might be called a "fully qualified name", if that terminology is correct. So my next attempt was "=Forms!frmMainNav.sfrmMainNav.frmConfigureSampleGroupSpecs.cboSelectSite.column(1)"
Now, that made sense to me but apparently not to Access. So, I tried several others including "=Forms!frmMainNav.sfrmMainNav.Form!frmConfigureSampleGroupSpecs.cboSelectSite.column(1).
After multiple tries, and a lucky guess, this simple little syntax below worked:
=[Forms]![frmMainNav].[sfrmMainNav]![cboSelectSite].[column](1).
Can you explain to me please how this can possibly work? How is it possible that Access can know which subform this combo cboSelectSite is on? The syntax above does not tell Access which subform to look at to find the combo, but it works??
__._,_.___
Posted by: david.pratt@outlook.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (2) |
Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.
.
__,_._,___
Tidak ada komentar:
Posting Komentar