Solved

Populate text boxes from query results

Posted on 2012-12-27
7
427 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Form performance table vs. query 27 71
I am having an ODBC timeout issue with an Access Frontend 6 61
Menus 6 57
Multiple tables for a tabbed form 2 33
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

751 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