Full Version: Expressions in form header
UtterAccess Forums > Microsoft® Access > Access Forms
eudaimonia
hi,
I want to have the form header of the Ag form show the Agreement name and number in the following format
greement: Title (Number)
I have the control source of the text box (fiormheadertitle) as follows
="Agreement: " & [Title] & " (" & [Number] & ")"
Strangely the expression displays correctly on some occassions, yet other times I get a #Name? error. I am not sure the reason for this inconsistent behaviour, however I have noticed it is more likely to fail when I first open the form.
I tried placing invisable Title and Number fields in the form header and ensured these occured prior to formheadertitle in the tab order - but this had not effect.
I also tried this - yet got the same inconsistent results
="Agreement: " & [Title] & " (" & Str([Number]) & ")"
I hope I am missing something really obvious here - if so I am quite happy to say D'oh with a smile!
eudaimonia
Rainlover
I think you will find that it is because Number is a reserved word.

But not 100% sure. Just 98.345%

so I am suggesting that you change Number in the Table to something like MyNumber
Edited by: Rainlover on Mon Feb 4 23:58:35 EST 2008.
Bob_L
What's probably happening is that the number is null and you'll get that when it is null (use the NZ function to handle the nulls).
lso, you should change that field name to something other than Number as it is a reserved word.
Rainlover
Hurry up Bob.
vtd
Try using the Form_Current Event to set the value of the TextBox in the FormHeader ...
eudaimonia
thanks for your help people sad.gif
Have changed the "number" field to "num" so it no longer uses a reserved word. Good spotting - thanks. I also changed the name of the control in the form to "num".
Unfortunately I get the same error. I don't believe its a null proplem as Bob suggested as the #Name? error appears even when both fields display correctly in the main form with non null values.
But I tried this anyway, and got the same error.
="Agreement: " & [Title] & " (" & Nz([Num]) & ")"
eudaimonia
vtd
Have you tried the Form_Current Event?
Rainlover
IMHO There is nothing wrong with your Code.

Suggest you post the form and table.

Edit

If you post then convert to 2000 first.
Edited by: Rainlover on Tue Feb 5 21:15:18 EST 2008.
eudaimonia
an update - thanks very much to people for their help
split the database and did a compact and repair and the problem disappeared!
Rainlover
Thanks for getting back to us.
Perhaps it was the reserved word, perhaps not. there is no real way of knowing at this stage.
Search UA for reserved words and you will find a list for future reference.
Good luck with this and future projects.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.