473,385 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How can I populate a text box with queried data from a combo box on the same form?

119 100+
Hi there.

This is probably an easy task, but I am new to Access.

I have a combo box called cboSymbol. I want to allow a user to select a symbol and then display the corresponding description of that symbol in a text box.

I think I need a way of executing an SQL statement that looks something like this:

desString = "SELECT Description from Assets WHERE Symbol = " & cboSymbol.Value & ";"

So the answer to the query is returned and stored as a string in desString. I can then set the value of the text box to display the returned query:

txtBoxDescription.Value = desString

Does anyone know how to execute a SQL command and store the returned value as a string, or know a different way of accomplishing this?

Thanks!
Dec 1 '06 #1
4 1933
NeoPa
32,556 Expert Mod 16PB
You need to set the ControlSource of the TextBox to point to the ComboBox required.
Dec 1 '06 #2
ADezii
8,834 Expert 8TB
Hi there.

This is probably an easy task, but I am new to Access.

I have a combo box called cboSymbol. I want to allow a user to select a symbol and then display the corresponding description of that symbol in a text box.

I think I need a way of executing an SQL statement that looks something like this:

desString = "SELECT Description from Assets WHERE Symbol = " & cboSymbol.Value & ";"

So the answer to the query is returned and stored as a string in desString. I can then set the value of the text box to display the returned query:

txtBoxDescription.Value = desString

Does anyone know how to execute a SQL command and store the returned value as a string, or know a different way of accomplishing this?

Thanks!
'NeoPa's approach uses the Pull Method to populate the Text Box. You can
'also 'Push' the value into the Text Box via:

'In the AfterUpdate Event of the Combo Box
Expand|Select|Wrap|Line Numbers
  1. Me![txtBoxDescription] = DLookup("[Description]", "Assets", "[Symbol] = '" & _
  2. Me![cboSymbol] & "'")
Dec 1 '06 #3
billelev
119 100+
Very nice. Thanks guys. I implemented the second method.

With the first method, I was able to link a Event Procedure to the text box [cboSymbol].[AfterUpdate]. To then update the text box, what would I do? I tried keeping the code that set the text directly...

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboSymbol_AfterUpdate()
  2.     txtBoxDescription.Value = DLookup("[Description]", "Assets", _ 
  3. "[Symbol] = '" & Me![cboSymbol] & "'")
  4. End Sub
...but I got the following error message...

"You can't assign a value to this object."
Dec 1 '06 #4
NeoPa
32,556 Expert Mod 16PB
You haven't included the & before the _.
Dec 2 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: godber | last post by:
I need to populate text boxes for instance with employee information using their unique employee works number selected from a combo box. Can anyone help, I am told thru visual basic this can be...
1
by: Cindi | last post by:
Hi, Another newbie with a question that I hope someone can point me in the right direction. The goal is to populate a text box with data according to the selection in a combo box while still...
4
by: bill.brennum | last post by:
Hi, This is probably a question with a simple answer, but here goes. I have a form linked to a table. There is a field on that table that while not showing on the form, I would like to...
4
by: Mike L | last post by:
I'm open for any suggestions on how to better program this. I want the user to select a license from a combo box, cboPrivilege and then the user will click the add button, then a record will be...
3
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to...
3
by: David | last post by:
I am trying to use Dlookup to populate a text box on a form, but haven't had any good luck so far. I've looked here at the posts and have used the Access help for examples. Northwind is way over...
4
by: whamo | last post by:
I have the need to populate a field based on the selection in a combo box. Starting out simple. (2) tables tbl_OSE_Info and tbl_Input; tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt...
5
by: giandeo | last post by:
Hello Experts. Could you find a solution for this problem please! I have the following tables in Access Database Table Name: origin Fields Names: country, countrycode Table Name: make...
2
by: Ronald | last post by:
I hope somebody can help. I can't get into the specifics of my project, but I'll try to create a simple example: tblVehicle * VIN (text box) * Make (text box) * Model (text box) frmRepair
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.