Solved

Displaying Name in Text box

Posted on 2011-03-04
8
293 Views
Last Modified: 2012-06-22
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
0
Comment
Question by:Chrisjack001
  • 4
  • 4
8 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 35036901
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
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 35036927
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
 

Author Comment

by:Chrisjack001
ID: 35037905
I want the name of the Person associated with that Person_Nbr to display in the text box above
0
 

Author Comment

by:Chrisjack001
ID: 35037968
Where on the form should I put this code
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 119

Expert Comment

by:Rey Obrero
ID: 35038002
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
 

Author Comment

by:Chrisjack001
ID: 35038198
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
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 35038246

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
 

Author Closing Comment

by:Chrisjack001
ID: 35038405
Thank you very much for your help. You were patient, professional and very knowledgeable about the problem.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now