Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Sunday, July 31, 2011 8:00 PM
Using Access 2010 and Win7, 64b, Home. I have a text box Control with a custom funkction as the row source. The function is in a standard Module and refers to the Control like this:
lngEmpl = Forms![frmOvertime].[txtEmpID]
This works fine when opening the frmOvertime and navigating through the records. However, inserting this frmOvertime as a subform in a Navigation Form, the code gives me an error. I found that I may be had to change my code to this:
lngEmpl = Forms!frmMAIN.frmOvertime.Form.txtEmpID
Unfortuneatly also this code returns an error? What am I doing wrong?
Any Help is very much apprieciated.
Regards
Jan T.
Sunday, July 31, 2011 9:08 PM ✅Answered | 1 vote
when you put the form into a navigation form it actually becomes a subform of the navigation form, you'll have to reference it as such.
try
Forms!frmNavigation!frmMain.Form!frmOvertime.Form.txtEmpID
For the benefit of others, please mark posts as answered or helpful when they answer or assist you in finding the answer. ...Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. - Mark Twain
Tuesday, August 2, 2011 5:10 AM ✅Answered
Hi AnonyMemous,
Thank you for posting in our forum.
You can use the following statement to refer to subforms.
Forms!YourMainFormName.YourSubformControlName.Form.YourControlName
Here is a good article by Bob for you. It tells us how to remember to refer to subforms in an easy way.
http://www.btabdevelopment.com/ts/ewtrhtrts
I hope this will help you resolve the issue.
If the issue persists, please feel free to let me know.
Best Regards,
Macy Dong [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Thursday, August 11, 2011 9:50 PM
Thank you for your answer. frmMain is actually the frmNavigation. Don't understand why I cannot reference it like I do:
lngEmpl = Forms!frmMAIN.frmOvertime.Form.txtEmpID
Thanks anyway.
Regards
Jan T.
Thursday, August 11, 2011 10:15 PM
try something like this ... literally
Forms!frmMain.NavigationSubform.Form.txtEmpID
For the benefit of others, please mark posts as answered or helpful when they answer or assist you in finding the answer. ...Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. - Mark Twain
Thursday, August 11, 2011 10:41 PM
the default name when you add the subform is NavigationSubform, you can change the name by clicking on the form and changing the name propertyFor the benefit of others, please mark posts as answered or helpful when they answer or assist you in finding the answer. ...Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. - Mark Twain
Friday, August 12, 2011 2:38 AM
Hi AnonyMemous,
Thank you for your response.
Have you read the article I gave you in the previous reply? I do think it is a good article about how to reference to sub forms.
Your sentence:
Forms!frmMAIN.frmOvertime.Form.txtEmpID
I think we should make sure:
frmMAIN is the name of your main form.
frmOvertime is the name of your subform control.
texEmpID is the name of the control on your subform.
I advise you check the three names carefully again.
The following statement is the correct way to reference to sub form.
**Forms!YourMainFormName.YourSubformControlName.Form.YourControlName **
Then lngEmpl is not very clear to me. Is it a variable in your function? At first I think Forms!frmMAIN.frmOvertime.Form.txtEmpID is the Control Source of the text book.
Is "lngEmpl = Forms!frmMAIN.frmOvertime.Form.txtEmpID" only one statement in your function?
If yes, you should write:
lngEmpl = Forms!frmMAIN.frmOvertime.Form.txtEmpID.Value instead.
Also, I think –suzyQ’s idea is very helpful.
I hope this will help you resolve the issue.
If you think my reply is not helpful, please feel free to unmark it.
If you have any other concerns, please feel free to let us know.
Best Regards
Macy Dong [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Friday, August 12, 2011 6:30 AM
I think the problem the poster is having is that even though his sub-form name is frmOvertime when it is put into the navigation form that replaced the old switchboard, it doesn't use the form's name as the default name for the form the navigation subform control's default name is literally NavigationSubform, so unless the poster changed that name to frmOvertime, it is not being referenced by the correct name.
For the benefit of others, please mark posts as answered or helpful when they answer or assist you in finding the answer. ...Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. - Mark Twain
Sunday, August 21, 2011 9:37 PM
Thank you! That worked!! I changed the form name referenced from frmOvertime til NavigationSubform and I works OK.
I use a variabel called lngEmpl to hold the EmplID in a function like this:
lngEmpl = Forms!frmMain.NavigationSubform.Form.txtEmpID
the old one that did not work: lngEmpl = Forms!frmMain.frmOvertime.Form.txtEmpID.value
Thank you all for good suggestions!
However, my workaround was to call a Private Function called from frmOvertime.txtMyTextBox. That is the txtMyTextBox.Controlsource = myPrivateFunction.
Thanx again
Regards Jan T.