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

textbox and or table select item from list box?

Status
Not open for further replies.

aarontra

Programmer
Oct 2, 2002
50
US
I have a form with a list box and a text box that both update a table to saves a value in a table which I use in some reports. Sometimes I know what the ClassID number is and just type it in the text box and press the button other times I select the ClassID from the list box.

This all works fine but what I want to add is the list box to have selected (hightlighted) the ClassID saved in the Table. Of course if I click on the item in the list I want it is selected but it does not work when I first open the form or if I type in the ClassID in the textbox and press the button.

I can't get it to work. Any help would be appreciated.
Thank you
Aaron


Table: Class_saved
ID
ClassID

List Box: Class_List
Default Value =[Class_saved]![ClassID]
On click:
Code:
CurrentDb.Execute "Update Class_saved Set ClassID = " & Me.Class_List.Value & " where ID = 1", dbFailOnError

Text box with button that also updates table Class_saved.


 
Is your form unbound? If not, what is the recordsource?
Is your list box Multi-Select property set to NONE?
Does your list box have a Control Source?
Does your text box have a Control Source?

I just made a bound form, with the List Box and Text Box both have the same Control Source (in your case, the ClassID). It works just how you want it to: When I open the form, the ClassID is filled in the Text Box, and the List Box has a selection of the ClassID for that record. If I go to a new record, neither are filled in. As soon as I fill in the text box, the List Box selects the same record. Alternatively, as soon as I select something in the List Box, the Text Box changes to that same ID.


Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you
GingerR

Your questions helped me figure it out.

Now the textbox updates the list box.

Code:
Me.Class_List = Me.ClassID_textbox

and the list box updates the textbox

Code:
Me.ClassID_textbox = Me.Class_List

Thanks again
Aaron

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top