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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to select the two list boxes and get the value in the text box.

Status
Not open for further replies.

rbasram

Programmer
Sep 27, 2001
53
CA
I have two listbox lst1 and lst2 what I am trying to do is that when the user suppose the user selects an item in lst1 and one item in lst2 I want to pass the results to a query and then dispay the result in the text box.

I know how to pass the parameters into the query but The only thing I don't understand is where to put the procedure for the text box. Is in the after update of the textbox or in the list box or in the form.

Any help will be aprreciatred...
 
Result goes in a text box?

Hmmmm....

Well, Access won't like displaying results of a query in a textbox. A query normally has multiple results whereas a textbox is for a single input.

Now, you could change the text box to a list or combo box and then use the requery methos on both of the after update events on the original two list boxes.

OR

You could create a subform and have it update in the same way.

OR

If you insist on a textbox, it's recordsets and VBA for you!

Create a public sub with parameters of the values of the listboxes, use SQL to create the recordset, do a MoveFirst on the recordset and then set the value of the text box.

Craig
 
I tried to to use only one lstbox now this is what I wrote in the contrl source property of the text box but it gives me the #Name? message...

Any suggestion. All I want to do is to pass the parameter to the query and get only one fiels just for display I am doing nothing with this fiels just for infomation like I want it to be more clear for the user that he is picking the right record.

Dlookup("[Title]", "QTitle", "[Tracking#]= '" & lstTNum.Column(0, intItem) & "'")
 
I think the problem may be as simple as the fact that you are putting what appears to be a number field in quotes. remove the quotes
Dlookup("[Title]", "QTitle", "[Tracking#]= " & lstTNum.Column(0, intItem)

also suggest you not use # symbol in field name access like to use that as a date field symbol.
good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top