tra5cie
10-07-2000, 07:42 AM
I'm trying to get a form to automatically concatenate [first name] and [last name] fields into one [full name] field. It seems a simple enough thing to do, I'm using a macro in the on enter event field in the [full name] field. When I click in the field, I get an error message that "The object doesn't contain the Automation object 'John'" i.e., the contents of the first name field in this record. Though when it gives the action failed dialogue box, the arguments say [full name], John Smith.
What am I missing?
Tra5cie
Rich@ITTC
10-07-2000, 09:25 AM
Hi Tra5cie (rather unusual name!)
Do you want another field/text box on your form to display the full name? If you do, then you do not need to store the name in a field (as you already have the data stored in [FirstName] and [LastName]fields in your table). Basing a field in a table upon other fields (i.e. a calculation or concatenation) breaks one of the fundamental laws of relational database systems (which rule or "Norm" it breaks is something I can never remember).
So what you want to do is to create a new text box on your form, but an unbound text box. You can use the toolbox in Design view to draw/create this new text box (you do not drag an existing field from the field list).
Then you make the Control Source property of that unbound text box draw upon the two fields concerned:
=[FirstName]&" "&[LastName]
This will always give you a concatenated field combining the names, but it won't store the combination within a field within a table (because you shouldn't duplicate things you have already stored elsewhere).
HTH
Rich
tra5cie
10-07-2000, 10:52 AM
Rich,
THe 5 is silent. It's a long story.
Here's the thing. I was thinking that I _would_ store the full name because:
this is a database for a publisher. The names are the authors. I want to keep track of the authors and their addresses, bios, etc. That's one distinct table. In another table we have books where I keep track of Title, ISBN, etc. and, of course, author. One author might have more than one book, (and one book might have more than one author). i wanted to be able to have the main book information form keep track of the authors from the other table so that I don't need to rekey an author address every time John Smith writes a new book. I was going to use the concatenated full name in a combo box on the main form so that the user can select the right author if s/he's already in the system. I need to keep the fields separate for searching purposes (search by author last name), and I wanted to select from the full name in case John Smith is an author and Bob Smith is another author. Do you think that there is another way that I could tackle this problem? THe SetValue doesn't seem to work, but I don't think that your solution of not storing the info will help with the larger problem.
Thanks,
Tracie
tra5cie
10-07-2000, 11:08 AM
After I wrote the last reply, I realized what I should do is to have the combo box look up both firstname and lastname instead of just one concatenated name, and then I don't have to store it, but the results are the same. THanks!
Tracie
Rich@ITTC
10-08-2000, 03:43 PM
Hi Tra5cie
Glad to hear that you got it sorted.
Rich