Control Source Expression

B

BigAl.NZ

Hi,

I am designing a form and want to have a control that displays First
Name and Last name from two fields.

I have just two controls on this form "Last Name" which I dragged
across from fields onto the from, and "Full Name" which is a text box
i created.

When I set the full name control source to :

=[Last Name]&[First Name]

But I get #Name?

The interesting thing is that =[Last Name] works, presumeably because
it is a control on the form, but =[First Name] doesnt?

What am I missing?

-Al
 
B

BigAl.NZ

Okay, I figurered it out, I have to set the forms record source to :

SELECT Customers.[Last Name], Customers.[First Name] FROM Customers;

so, from this I take it that a form cant refer to anything that isnt
declared in record source?

How would you then set a form to get a record from two tables?

-Al
 
A

Allen Browne

Change the Name property of the control (on the Other tab of the properties
box.) Access gets confused if the control has the same Name a a field, but
is bound to something else.

If that doesn't work, check if the space in the name is correct.

Ultimately you will probably want to add a space between the 2 names, e.g.:
=[Last Name]& ", " + [First Name]
 
L

Larry Linson

Okay, I figurered it out, I have to set
the forms record source to :

SELECT Customers.[Last Name], Customers.[First Name] FROM Customers;

so, from this I take it that a form cant
refer to anything that isnt declared in
record source?

How would you then set a form to get
a record from two tables?

Use a Query for the Form's RecordSource rather than using a Table, with
multiple tables joined in the Query. Read carefully the Help on "updateable
queries" -- often making a query updateable is as simple as being sure to
include the Primary Keys from both (or all) Tables in the Query.

If there is a one-to-many relationship between the two tables, you might use
a Subform, in which you have embedded a Form showing the Records from the
related (many side of the Relationship) Table.

Larry Linson
Microsoft Access MVP
 
B

BigAl.NZ

Okay, I figurered it out, I have to set
the forms record source to :

SELECT Customers.[Last Name], Customers.[First Name] FROM Customers;

so, from this I take it that a form cant
refer to anything that isnt declared in
record source?

How would you then set a form to get
a record from two tables?

Use a Query for the Form's RecordSource rather than using a Table, with
multiple tables joined in the Query. Read carefully the Help on "updateable
queries" -- often making a query updateable is as simple as being sure to
include the Primary Keys from both (or all) Tables in the Query.

Hmmm, interesting, you want to include both Primary keys, different to
including both related keys?

How does including both Primary Keys help? Can you explain a bit
more....

Cheers

-Al
 
L

Larry Linson

How does including both Primary Keys help?
Can you explain a bit more....

No, I can't. I was just perfectly happy, some years ago, to learn that many
update problems were easily avoided by ensuring that the PK of the table to
be updated was in the RecordSource. If a "why" was explained to me, at that
time, I don't remember it -- but there are a lot of internals items that
Microsoft has not chosen to make public.

Larry Linson
Miicrosoft Access MVP
 
Top