Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic Question

Status
Not open for further replies.

cloakski

Programmer
Dec 13, 2002
8
US
I'm new to Access and learning as I go. I have a text box that I am loading with data from a table once a combo box selection is made. I want the text box to be filled with the result of a query. However my code puts the exact string of the query into the text box.

[Description] = "SELECT Description FROM SoftwareCriticalLevels WHERE Number = '" & Me![SCL_Combo] & "'"

How do I put the result of the query into the text box?
 
in the after update of the combobox put
[Description] = Me![SCL_Combo]
 
That only gives me the selected Item number, I need the query to be done with that number, as stated in my other post. When I put that code in After Update, it just puts a number in the textbox.
 
i dont understand what it is that you want
try makeing a multi column combobox and in the after update of the combobox put
[Description] = Me![SCL_Combo].column(index)
remember that combobox index start a 0 so that the seconed column is column is column(1) and so on







 
Ok basically this is what I want to know. How do I take the result of a query and put it in a text box.

So if my query is this.

"SELECT * FROM FooTable WHERE ID = '2'"

How do I capture that result and put it into a text box to display to the user?
 
what are the fields in your table and what do you want to see in your text box give me an example
if you want to see all Description where id =2 as indicated in youe last reply try useing a list box
 
Use DLookup() in the combo box's AfterUpdate event procedure:
Code:
    Private Sub SCL_Combo_AfterUpdate()
        Me![Description] = DLookup("Description", "SoftwareCriticalLevels", _
            "Number = '" & Me![SCL_Combo] & "'")
    End Sub
DLookup() actually builds a query from its arguments:
SELECT <arg1> FROM <arg2> WHERE <arg3>
'arg1' should specify a single column, and the query should return a single row. If it returns multiple rows, DLookup() returns Null. Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
if you want to know how to update the list box see

thread702-433560
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top