Displaying Name in Text box

I have a form in a database that I want the name of the user display in a text box when that user inputs their Person_Nbr and select a Month/year date. The source of the names are in the NAME field of the ppm table. Example when the user inputs 11111 as Person_Nbr the name that should display should be Melanie Davies in the Text box. Attached is the Database. Can you please help me accomplish this goal. I have tried different methods but I could not still get it to work. Thanks
Database11.mdb
Chrisjack001Asked:
Who is Participating?
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:

Private Sub txtPerson_AfterUpdate()
Dim strName As String
strName = DLookup("[name]", "ppm", "person_nbr = " & Me.txtPerson)

Me.Text18 = Trim(Split(strName, ",")(1)) & " " & Split(strName, ",")(0)
End Sub

0
 
Rey Obrero (Capricorn1)Commented:
your db is working, when you enter the number in txtPerson and select a date from the combo box..

what is it that you want as an alternative?
0
 
Rey Obrero (Capricorn1)Commented:
you can try this,

Private Sub txtPerson_AfterUpdate()
Dim strsql
strsql = "Select * from ppm where person_nbr = " & Me.txtPerson
Me.RecordSource = strsql

End Sub
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
Chrisjack001Author Commented:
I want the name of the Person associated with that Person_Nbr to display in the text box above
0
 
Chrisjack001Author Commented:
Where on the form should I put this code
0
 
Rey Obrero (Capricorn1)Commented:
first remove the Control source of the textbox, then use this codes

Private Sub txtPerson_AfterUpdate()


Me.Text18 = DLookup("[name]", "ppm", "person_nbr = " & Me.txtPerson)
End Sub
0
 
Chrisjack001Author Commented:
It works great. Is it possible to flip the Last Name, First name around and for it to display it as
Payroll Payment for "FirstName LastName"
0
 
Chrisjack001Author Commented:
Thank you very much for your help. You were patient, professional and very knowledgeable about the problem.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.