Put the result of a query into textbox

jpl458

Well-known member
Local time
Today, 11:52
Joined
Mar 30, 2012
Messages
1,200
I have a data entry form that logs phone calls. I also have a zip code table with all the zip codes in the US. from the phone number textbox I can get the area code using:


Private Sub callingnumber_LostFocus()
Dim acode As Variant
acode = Mid(callingnumber, 1, 3)
Me.callorigin = acode

That puts the area code into a textbox. I want use the data in that textbox in a query to get additional; info into 2 other text boxes; Region and Description.

the query(luZipcode) in SQL is:

SELECT areacodetbl.Region, areacodetbl.Description
FROM areacodetbl
WHERE (((areacodetbl.Region)="210"));


DoCmd.OpenQuery "luZipcode", , acReadOnly

how do I get the results of that query into text boxes?(Region and Description)?

Thanks
 
You could try using DLookup().
 
First, will you be storing [Region] and [Description] in a table other than areacodetbl? If so, that is incorrect, you shoudl not do that.

If you simply want to display those values on the form and not store them in a table other than areacodetbl, then you should use a DLookup for each of the text boxes:


Give that link a read, try it with your data and if things don't work, post what you tried back here.
 

Users who are viewing this thread

Back
Top Bottom