Empty Text box

T

TimH

Thank you in advance!
I have a TxtName unbound and i would like to populate it with the
name(LastName, FirstName) that is bound to iether ID(primaryKey) or
SSN(bound).
something like :
If len(SSN) =>0 Then

txtName = "Me.ID" & "LastName, " & "FirstName"

End if


I have tried to run this code in a number of event but it is not working.
Please Help.
 
D

Douglas J. Steele

You need the references to the fields to be outside of the quotes:

If Len(Me.SSN & vbNullString) > 0 Then
Me.txtName = Me.ID & ": " & Me.LastName & ", " & Me.FirstName
End If

The "Me." keyword is there to ensure that Access realizes that SSN, txtName,
ID, LastName and FirstName are all either controls on the form or fields in
the form's RecordSource.

The reason for adding vbNullString to Me.SSN in the Len function is to
ensure that it handles Null fields correctly.
 
T

TimH

Again I thank you; It worked.
--
timH


Douglas J. Steele said:
You need the references to the fields to be outside of the quotes:

If Len(Me.SSN & vbNullString) > 0 Then
Me.txtName = Me.ID & ": " & Me.LastName & ", " & Me.FirstName
End If

The "Me." keyword is there to ensure that Access realizes that SSN, txtName,
ID, LastName and FirstName are all either controls on the form or fields in
the form's RecordSource.

The reason for adding vbNullString to Me.SSN in the Len function is to
ensure that it handles Null fields correctly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top