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
Solved

Populate text boxes from query results

Posted on 2012-12-27
7
425 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

829 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