Auto populate a text box based on the selection of a combo box (1 Viewer)

julesfurman

New member
Local time
Yesterday, 19:58
Joined
May 25, 2013
Messages
6
Hello,

I am new to Access (I'm sure you've heard that before) ;)
Any help would be greatly appreciated ...

Let me break this down for ya -
I have two tables: tblWeightTickets and tblWasteType
I want to create a form: frmWeightTickets, where a user can enter information and the data is stored in tblWeightTickets.
There are two fields in particular that I am working on ... "WasteType" and "Rate". On the form, I want "WasteType" to be a combobox "cboWasteType" and when I select a type of waste I want the "Rate" textbox on the same form to auto populate with the rate amount for that particular type of waste (i.e. recycling, garbage, etc). The Rate amount is located in the table: tblWasteType under the field name "Rate". How can I do this and at the same time store the information in the tblWeightTickets?
I hope that is clear ... please let me know if I can clarify anything.
I already have the combo box loaded with the types of waste - I just need it to populate the rate text box and store it in the Weight Tickets table.

Thank you so much for any help given!!
 

John Big Booty

AWF VIP
Local time
Today, 12:58
Joined
Aug 29, 2005
Messages
8,263
Welcome to the forum.

You can populate an unbound text box by using the following as it's Control Source;
Code:
=[ComboName].[column]([B][COLOR="Red"]X[/COLOR][/B])
Where X represents the column in the combo that hold the data you wish to display, remember that the columns in a Combo or listbox for that matter are numbered from zero on up.

Check the attached sample.
 

Attachments

  • Populate Text Box from Combo.zip
    1.5 MB · Views: 2,736

julesfurman

New member
Local time
Yesterday, 19:58
Joined
May 25, 2013
Messages
6
Thank you for your fast response!
I'll have to try it when I return to work on Tuesday ... I don't have MS Access on my home computer ...
I'll let you know how I do ...
Thanks again :)
 

julesfurman

New member
Local time
Yesterday, 19:58
Joined
May 25, 2013
Messages
6
Thanks, Big Booty ;)
With a few attempts I got it to work! My text box now populates with the correct rate based on what I select with the combo box! :) Much appreciated!
BUT now I have another problem! (I bet you knew that was coming) - lol
My form is working perfectly now, but not all fields are getting saved into the appropriate table. I want ALL fields on the form (frmWeightTickets) to be saved into my table (tblWeightTickets). All fields are getting saved to the table except two of them ... any ideas? One of the fields is the textbox that is filled in by the selection of the combo box and the other is a text box that holds a calculation ...
 

John Big Booty

AWF VIP
Local time
Today, 12:58
Joined
Aug 29, 2005
Messages
8,263
The field that is being derived from the combo and the calculated field, should in most cases not be saved. If one of the underlying values is changed this may not be reflected in your stored value.

All you need to do is use a query or the same schema you are currently using to populate those fields, whenever you need to display them.
 

julesfurman

New member
Local time
Yesterday, 19:58
Joined
May 25, 2013
Messages
6
Forgive me because I am so new to this and I'm sure I that what I have created (even though it is working) is probably not set up in the most efficient way. To me, if those two fields are not stored in the table, then in my opinion the table is worthless. Is there any code that I can add to my form to save those fields in my table?

Thanks again -
Julia
 

John Big Booty

AWF VIP
Local time
Today, 12:58
Joined
Aug 29, 2005
Messages
8,263
So long as the you have the basis for your calculation stored, the result (in most cases) does not need to be stored, as it can be reconstituted at any time you need to display the result. Read here for more.

You might also want to read up on data normalisation and perhaps work through a tutorial on the subject.
 

julesfurman

New member
Local time
Yesterday, 19:58
Joined
May 25, 2013
Messages
6
Thanks again ... I will definitely read up on the links you provided :)
 

julesfurman

New member
Local time
Yesterday, 19:58
Joined
May 25, 2013
Messages
6
Thanks, again. I'm not sure I understand why I can't have a calculation in a table, but I can see that I have a lot to learn, so I won't question it. I created a query that holds the calculation and the rest of the data I need. Thank you for your help!
 

qaaccess

Registered User.
Local time
Yesterday, 19:58
Joined
Jul 23, 2014
Messages
18
I am trying to populate multiple text boxes from combo box using one table. First text box is getting populate on base of combo box value while 2nd text box is not getting populating.

I have used the following to populate the text boxes, even row count is correct, But why is not 2nd text box is not populating ?

=[Combo2].[Column](1)
=[Combo2].[Column](2)

Please help me in this regard. thanks.
 

qaaccess

Registered User.
Local time
Yesterday, 19:58
Joined
Jul 23, 2014
Messages
18
I am trying to populate multiple text boxes from combo box using one table. First text box is getting populate on base of combo box value while 2nd text box is not getting populating.

I have used the following to populate the text boxes, even row count is correct, But why is not 2nd text box is not populating ?

=[Combo2].[Column](1)
=[Combo2].[Column](2)

Please help me in this regard. thanks.

Dear All waiting for reply
 

qaaccess

Registered User.
Local time
Yesterday, 19:58
Joined
Jul 23, 2014
Messages
18
I am trying to populate multiple text boxes from combo box using one table. First text box is getting populate on base of combo box value while 2nd text box is not getting populating.

I have used the following to populate the text boxes, even row count is correct, But why is not 2nd text box is not populating ?

=[Combo2].[Column](1)
=[Combo2].[Column](2)

Please help me in this regard. thanks.

One thing I noted when I provide the control source then selection gets stop from combo box...Could it be the reason I am giving the valid control source is customerID but its not working.
 

jai kushwaha

Registered User.
Local time
Today, 08:28
Joined
Nov 1, 2015
Messages
61
hello dear friend
i have a combo box name "Cbo_species" and in that combo box there are 7 or 8 values what i want when i choose only one value from the combo box, the text box i have in front of my combo box name "species_name" will appear and enable for edit and ask the name but if i choose any other option it will not ask the name, i mean it will disable and also invisible.
 

Users who are viewing this thread

Top Bottom