Solved

Populate text boxes from query results

Posted on 2012-12-27
7
414 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
Comment Utility
< 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
Comment Utility
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
Comment Utility
or something like this; if you are (for example) selecting a tech for a job...
Database4.accdb
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:sptech
Comment Utility
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
Comment Utility
OK,
Keep me posted and Enjoy the New Year!

;-)
0
 

Author Comment

by:sptech
Comment Utility
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
Comment Utility
Thank you boog2000.  Your solution works great.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

763 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

9 Experts available now in Live!

Get 1:1 Help Now