Proper Names

Mrsostrich

Registered User.
Local time
Today, 23:01
Joined
Sep 28, 2002
Messages
21
Is there an easy way I can set a table field to automatically put names with an initial upper case letter followed by a lower case?

Am I right in thinking I can't use a calculated field as a primary key?
 
Use the StrConv function to convert to do the text conversion.

Strictly speaking, calculated fields are available only in queries, forms and reports, not tables. However, you may be able to accomplish the same thing by using an expression in the DefaultValue property of a table field (whether or not it is the key field). The limitations on that approach include:

1. Only certain types of expressions are allowed in the DefaultValue property, and these don't include user-defined functions.
2. A true calculated field is re-calculated whenever the query or report is run, or a record is displayed in the form, whereas the DefaultValue property only applies to the INITIAL value of the field in NEW records.
 
Key Fields

What I actually want to do is create a key fiels which matched the format we use for user names on our network, which is 4 characters of surname plus 2 of forename. The left function creates it perfectly, but I'd then like to use it as a primary key. I can do it by running an append query I think, just wondered whether i needed to.
 
What you're talking about is how you construct the value to be inserted into the key field, not a calculated field. Using something like Left$([Surname], 4) & Left$([Forename], 2) should work fine, assuming the resulting expression is always unique. All this is independent of whether you are adding records via an append query or ADO/DAO in VBA code.
 

Users who are viewing this thread

Back
Top Bottom