Answered by:
Difference between Access 2010 and 2013 referencing field names vs control source name

Question
-
When implementing code developed in 2010 in a 2013 environment, I have run into the following difference which can affect upgrading.
In 2010 when referencing a form field whose Name (in the Other tab) is txt10 (for example) and its field name in Control Source is FiscalYear (for example), referring in code to this field as Me.FiscalYear works fine.
In 2010 this same reference throws an error. It requires it to be Me.txt10 to work properly or requires renaming the txt10 field to FiscalYear.
Marj Weir
Tuesday, March 15, 2016 7:04 PM
Answers
-
Thank you for you effort on this. The context of this situation is that I am developing in 2010, but installing at another site to 2013. The code was identical, but worked without issue in 2010, but errored at the 2013 site. I have changed the code in 2013 so the the Control Source name and the form field name (in Name under the Other tab) are the same and the code worked without alteration. FiscalYear versus Fiscal Year was not the problem.
Do you find this same problem for any bound form, in any database running under Access 2013?
Is this happening on a form where you dynamically set or change the RecordSource at run time?
Normally, Access adds all the controls on the form and all the fields in the form's recordsource as properties of the form, when the RecordSource is assigned in design view. If the recordsource is set at run-time, though, the fields in the recordsource are not available as properties of the form. That's the only circumstance where -- so far -- I've encountered the problem you describe.
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html- Marked as answer by David_JunFeng Thursday, March 24, 2016 8:50 AM
Sunday, March 20, 2016 9:26 PM
All replies
-
Hi Marj. Just for fun, could you try using the bang operator in both versions just to see if you get the same problem? For example, try using Me!FiscalYear.Tuesday, March 15, 2016 7:17 PM
-
When implementing code developed in 2010 in a 2013 environment, I have run into the following difference which can affect upgrading.
In 2010 when referencing a form field whose Name (in the Other tab) is txt10 (for example) and its field name in Control Source is FiscalYear (for example), referring in code to this field as Me.FiscalYear works fine.
In 2010 this same reference throws an error. It requires it to be Me.txt10 to work properly or requires renaming the txt10 field to FiscalYear.
I was unable to reproduce this in a simple test, and I think I would have encountered it as a problem before if it were generally the case. Could it be there is something in particular about the field, control, form, or database that is causing it to be a problem in this case? The most obvious, of course, is that the field name in the form's recordsource may not in fact be "FiscalYear", but rather "Fiscal Year" or some other variation that you could have overlooked. Another possibilty that comes to mind is that the form's recordsource may be assigned dynamically, so that at design time the field "FiscalYear" hasn't yet been assigned as a property.
If it's neither of those, could you maybe post an example database where we could download it for investigation?
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.htmlTuesday, March 15, 2016 8:23 PM -
Thank you for you effort on this. The context of this situation is that I am developing in 2010, but installing at another site to 2013. The code was identical, but worked without issue in 2010, but errored at the 2013 site. I have changed the code in 2013 so the the Control Source name and the form field name (in Name under the Other tab) are the same and the code worked without alteration. FiscalYear versus Fiscal Year was not the problem.
I don't have 2013 so I can't do tests myself.
Thanks again.
Saturday, March 19, 2016 7:41 PM -
Hi. You didn't mention if you tried my suggestion.Saturday, March 19, 2016 10:33 PM
-
Thank you for you effort on this. The context of this situation is that I am developing in 2010, but installing at another site to 2013. The code was identical, but worked without issue in 2010, but errored at the 2013 site. I have changed the code in 2013 so the the Control Source name and the form field name (in Name under the Other tab) are the same and the code worked without alteration. FiscalYear versus Fiscal Year was not the problem.
Do you find this same problem for any bound form, in any database running under Access 2013?
Is this happening on a form where you dynamically set or change the RecordSource at run time?
Normally, Access adds all the controls on the form and all the fields in the form's recordsource as properties of the form, when the RecordSource is assigned in design view. If the recordsource is set at run-time, though, the fields in the recordsource are not available as properties of the form. That's the only circumstance where -- so far -- I've encountered the problem you describe.
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html- Marked as answer by David_JunFeng Thursday, March 24, 2016 8:50 AM
Sunday, March 20, 2016 9:26 PM