Full Version: Why does this cause #Error to be displayed?
UtterAccess Forums > Microsoft® Access > Access Forms
markmcrobie
In my form header I have a text box set to:
"Extra information for " & [TaskCode] & ""
TaskCode is definetely a field in my underlying query. And I get the same error even if I put the text box in the Detail section.
MStef
Try:
="Extra information for " & [TaskCode]
markmcrobie
Same error (#Error)
MStef
Check if there is a field TaskCode in query.
markmcrobie
There is, definetely - in fact it's the field TaskCode box I'm editing - I added TaskCode as a field, dragging it from the field list in the form, then I edit it to the text above.
I've also tried creating a new unbound text box and typing the statement in - same result.
markmcrobie
Hmm, it's working now for some reason - I didn't change anything!
markmcrobie
Now it's not working again!
rrghhh!
MrSiezen
Are there more tables or queries in the form's recordsource which contain a field with the same name? If so, add the proper table or query name.
markmcrobie
Ok, having the text box set to:
qryExtraInfo]![TaskCode] or:
=[qryExtraInfo]![TaskCode]
both give a #Name error
MrSiezen
Nope, beats me! All I can suggest now is compacting and compiling. And maybe add a sample db so we can check it ourself?
cheekybuddha
Perhaps the problem is caused if [TaskCode] might contain Nulls sometimes.
ry:
=IIf(Len([TaskCode] & "") > 0, "Extra information for " & [TaskCode], "")
hth,
d
markmcrobie
AFAIK TaskCode will never be Null.
tried your code anyway, but it still gives #Error.
Attached is a sample. Look at the text box in the header of frmExtraInformation.
Thanks
cheekybuddha
OK,
The problem lies in what I consider to be a serious shortcoming of Access.
When you create a form and drag a field from the filed list on to the form to create a control it gives the control the same name as the name of the field.
To avoid these errors you need to rename your controls differently.
So you have a control (textbox) called 'TaskList' with a ControlSource also 'Tasklist'
Rename the textbox to txtTasklist and all will be well.
Ostrongly suggest that when you add controls to forms you rename them with something meaningful that differentiates it from its ControlSource. I realise this is tedious but avoids many headaches down the line
Someone (Allen Browne I think) has written some code that will go through all the controls in your project's forms/reports and adjust the naming for you. I will try and dig out the link.
hth,
d
jmcwk
try changing the name of your control to TCode not TaskCode
ame: Tcode
Control Source:="Extra information for " & [TaskCode]
HTH
cheekybuddha
See whether sample 4 in this link can help you.
hth,
d
cheekybuddha
Oops! Of course i meant TaskCode, not Tasklist, in my post above! blush.gif
markmcrobie
Many thanks all, rnaming the text box to txtTaskCode worked!
That a pain!
markmcrobie
Thanks for the link, but I'm a bit scared to use it - will it look through *everything* (code and all) and rename accordingly? I'm worried it leave some of the old names in and cause all sorts of problems.
lso my only table is a linked ODBC one? Can this be renamed without wrecking the link?
MStef
Yes, change the NAME of this field. Now it is TaskCode, it is the seme as in query. It causes the error.
cheekybuddha
Hmm...
would advise making a backup (or several!) before running that code!!
If everything works now, then perhaps it's not worth trying to correct it now, but just bear in mind for the future.
However, if you're willing to take the plunge on a copy of your db then it would be useful for other members to know how effective the add-in is! wink.gif
hth,
d
MStef
Ok, I'm late, newer mind.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.