Urgent: How to construct functions for combining two fields for output on a form

  • Thread starter Thread starter Christine
  • Start date Start date
C

Christine

Perhaps I'm dense but I don't for the life of me
understand how to construct functions: what
command/information comes first, second, third, etc.

My current problem is this. On a form, I have set the
datasource for the form to Employees. I simply want to
trim the field LastName, add a comma (,) then show
FirstName. I have tried to enter function information in
the Data Control Source like this:

=Ltrim$(Last Name) + "," + First Name
and
=Name: LTrim$(Last Name) & "," & (First Name)

and everything inbetween, including the use of ([])
without success. This should be so simple - what am I
doing wrong??

Fast response will be greatly appreciated - I've wasted 1-
1/2 days already trying to figure this out.
 
Hi,
This works for me:
=Trim([lname]) & "," & [fname]

You have spaces in your field names so you definitely need the [ ]
 
My current problem is this. On a form, I have set the
datasource for the form to Employees. I simply want to
trim the field LastName, add a comma (,) then show
FirstName. I have tried to enter function information in
the Data Control Source like this:

=Ltrim$(Last Name) + "," + First Name
and
=Name: LTrim$(Last Name) & "," & (First Name)

In a Query calculated field you need an alias (your Name:) but the
alias isn't appropriate in a form/report textbox's control source.
Trim or Ltrim are only rarely really needed - Access trims trailing
blanks already, and unless you have wierd users there ordinarily
wouldn't be leading blanks. The + operator gives a NULL if either
field is NULL, so & would be a bit safer. Missing square brackets is
probably the problem (though you say you've tried them): Try

=Trim([Last Name]) & ", " & [First Name]

so that you get "Vinson, John" instead of "Vinson,John"

If that doesn't work, you may have a References problem. Open any
module in design view, or open the VBA editor by typing
Ctrl-G. Select Tools... References from the menu. One of the
..DLL files required by Access will probably be marked
MISSING. Uncheck it, recheck it, close and open Access.

If none are MISSING, check any reference; close and open
Access; then uncheck it again. This will force Access to
relink the libraries.
 
Back
Top