Avatar of Chrisjack001
Chrisjack001
Flag for United States of America asked on

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
Microsoft Access

Avatar of undefined
Last Comment
Chrisjack001

8/22/2022 - Mon
Rey Obrero (Capricorn1)

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?
Rey Obrero (Capricorn1)

you can try this,

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

End Sub
Chrisjack001

ASKER
I want the name of the Person associated with that Person_Nbr to display in the text box above
Your help has saved me hundreds of hours of internet surfing.
fblack61
Chrisjack001

ASKER
Where on the form should I put this code
Rey Obrero (Capricorn1)

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
Chrisjack001

ASKER
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"
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Rey Obrero (Capricorn1)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Chrisjack001

ASKER
Thank you very much for your help. You were patient, professional and very knowledgeable about the problem.