Solved

Populate text boxes from query results

Posted on 2012-12-27
7
420 Views
Last Modified: 2013-01-22
I have an Access DB with several tables.  I have a query:

"SELECT Techs.LName, Techs.FName, Techs.Email_Address
FROM Techs
WHERE (((Techs.LName)=[Forms]![Records]![txtLName]));"

What I need to do is:
1) run the query from code on the lost focus event of the txtLName.text
2) if more than one name (e.g I have 3 techs named smith) I need a popup that allows the user to select which "smith" they want to work
3) populate the txtFName.text box with the techs first name
4) populate the txtEmail.text box with the techs email address

I tried this: sSql = ("SELECT Techs.LName, Techs.FName, Techs.Email_Address FROM Techs WHERE Techs.LName= '" & [Forms]![Records]![txtLName] & "'")
this query works with access, but I would like to do this from code


since the form I am using is in access do I need to create a connection string?
I know I need a recordset to loop through the DB.

Man I think I bit off more than I can chew! Some day I will remember what NAVY actually means (Never Again Volunteer Yourself).
0
Comment
Question by:sptech
  • 4
  • 3
7 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38724063
< if more than one name (e.g I have 3 techs named smith) I need a popup that allows the user to select which "smith" they want to work>

Why is the last name only known?
Why can't you simply load all the tech's First and Last names in a combobox, ...and simply "Select" the correct tech?

Then none of the other "Pick the correct Tech" stuff is needed.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38724097
Not sure of your exact needs here, but try this as a start:

JeffCoachman
Database4.accdb
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 38724179
or something like this; if you are (for example) selecting a tech for a job...
Database4.accdb
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:sptech
ID: 38732132
Thanks for all the inputs.  I haven't tried them yet but I will this week.  As for  boag2000 comment on the combobox, it just never occured to me.  See this is what happens when you bite off more than you can chew.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38732682
OK,
Keep me posted and Enjoy the New Year!

;-)
0
 

Author Comment

by:sptech
ID: 38777213
My apologies to everyone who has commented.  My bosses have kept me on the road so I haven't had any time to look at or try the responses.  Please be patient, I haven't forgotten.  I will be back in the home office this coming Monday and then I will have time to work on this DB.  Thanks
0
 

Author Closing Comment

by:sptech
ID: 38805053
Thank you boog2000.  Your solution works great.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

863 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

21 Experts available now in Live!

Get 1:1 Help Now