Empty Text box

  • Thread starter Thread starter TimH
  • Start date Start date
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.
 
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.
 
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.
 
Back
Top