Saving Calculated Field

JJ

Registered User.
Local time
Today, 09:48
Joined
Mar 25, 2000
Messages
10
I know the general rule is to not save calculated fields, but in this case I am trying to calculate a unique identifier built from the first letter of [First Name], the first letter of [Last Name], and an autonumber [Client Number]. Thus, the form automatically creates a unique client number from input of the first name, last name, and the table autonumber, i.e. JJ-0250. I would then like to use this unique number as the primary key linking various tables. Might this be a case where I need to save the calculated field to the table and if so how do I accomplish that?
 
Something like this in the LastName.AfterUpdate property would work:

Dim strID as string, strMsg as String
strMsg = "You must enter both a first name and last name."
If Not IsNull(Me!FirstName)And Not IsNull(Me!LastName) And IsNull(Me!CaseID) Then
strID = Left([FirstName],1) & Left([LastName],1) & "-" & Trim(str(ClientNumber))
Me!CaseID = strID
Else
MsgBox strMsg
DoCmd.CancelEvent
Me!FirstName.SetFocus
End if

Be sure to substitute the actual field name for CaseID


[This message has been edited by Axis (edited 03-26-2000).]

[This message has been edited by Axis (edited 03-26-2000).]
 

Users who are viewing this thread

Back
Top Bottom