Solved

Populate text boxes from query results

Posted on 2012-12-27
7
428 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
Industry Leaders: 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!

 

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

617 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