473,406 Members | 2,439 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,406 software developers and data experts.

synchronizing one text field based on the selection of a drop down list

Hello folks,

I'm building a nutrition database to keep track of my eating habit. I know there's ton out there but I want to do it on my own you know?

Anyway there's a tiny issue that I cant seem to find the answer anywhere. Google is great but I cant seem to figure out the right key word to use to find the answer. Argh!

Ok, I have a table [food_by_calories] that has two columns which are [food] and [calories].

an example would be like this

[Food]..............[Calories]
Hamburger......350
Banana............40

Now, I have a look-up drop down menu that goes to the table and I can select any from the first column with no problem. I also have a text field right next to it that I want to automatically display calories depending on which one I select in the drop down menu.

Is there a way to do this?

Thx
Nov 17 '09 #1
11 5538
NeoPa
32,556 Expert Mod 16PB
Certainly. No problem.

Look at the .Column() property of the ComboBox control.

Let us know how you get on :)
Nov 18 '09 #2
@NeoPa
I looked at the combo Box property sheet and learned everything about column count and Bound Column. Dont see how it can help me in this situation.

I am trying to figure out how to get the text field to automatically select the corresponding data in the second column depending on the selection in the drop down field.

Example:

I would select Hamburger in the combo box and then the text field would check the table and see that the calories for hamburger is 300 and inserted it in the text field.
Nov 18 '09 #3
NeoPa
32,556 Expert Mod 16PB
They can't. It was the .Column() property I was referring to. It is accessed in VBA and gives you control, not only over which column is returned, but also which row if the currently selected row is not what you need.

As I say, I suggest you read up on that as I'm sure it completely fulfills your needs.
Nov 18 '09 #4
ChipR
1,287 Expert 1GB
You will need to use the After_Update event of the combo box control to change the text box.
Nov 18 '09 #5
NeoPa
32,556 Expert Mod 16PB
If it's a bound control you will also need to run the same code from the Form_Current() event procedure.

That one is often overlooked.
Nov 18 '09 #6
VBA? I have zero understanding of VBA. I searched .column in Access help and only presented info on column in property sheet.

Do you know of a website focused on VBA for novices?
Nov 18 '09 #7
NeoPa
32,556 Expert Mod 16PB
Try Microsoft Access Tutorial & VBA Tutorial (Excel).

I can't vouch for them particularly, but they seem to be decent places to start at least.
Nov 18 '09 #8
I'm back. I got a Access 2007 VBA book and learned a lot. So here what I did! For the most part it worked except for the very last part ;-(

I created a table titled [DoDAAC] that had three field names which are [ID] [CMO_Name] [DoDAAC1].

I also created a query titled [DoDAAC Query] that includes all fields from the DoDAAC table above.

I went into the main table titled [Data Collection] and created two field names which are [CMO Name] and [DoDAAC]. I set [CMO Name] to look up the DODAAC table.

Expand|Select|Wrap|Line Numbers
  1. SELECT [DoDAAC Query].ID, [DoDAAC Query].CMO_Name, [DoDAAC Query].DoDAAC_ FROM [DoDAAC Query] ORDER BY [DoDAAC Query].DoDAAC_;
The [DoDAAC1] field is just a text box.

I now created a query [Data Collection Query] which contains all fields from the [Data Collection] table

Now, I also created a CAR form and I added the two fields [CMO Name] and [DoDACC] from the Data Collection Query. The CMO Name field is a combo box and it works beautifully.

The text box [DoDAAC] is supposed to automatically fill its field depending on the Combo box's selection. So I went into the Text box's property sheet and modified the control source
Expand|Select|Wrap|Line Numbers
  1. =[CMO Name].column(3)
In the CAR form, the data would be filled into the text box as expected but refuse to store the data in a field which is [DoDAAC] for later use.

I also tried this
Expand|Select|Wrap|Line Numbers
  1. [DoDAAC]=[CMO Name].column(3)
So I tried it via VBA and it still wont work.

I am overlooking something and I have been spending more than 10 hours on this. I admit I need some help.

Matt
Dec 4 '09 #9
Can anyone point me in the right direction? is there a certain method of doing this that I overlooked?

Any help would be greatly appreciated and thank you in advance.

Matt
Dec 6 '09 #10
ChipR
1,287 Expert 1GB
The text box will only be updated based on the control source at certain times, like on load or current record. If you want to update the text box at other times, you will need to put code in to do so. To change the text box when the combo box changes, you would (still) use the AfterUpdate event of the combo box.
Dec 7 '09 #11
NeoPa
32,556 Expert Mod 16PB
So I tried it via VBA and it still wont work.
I think Chip is on the right lines here, but you give no details of the VBA you've tried so we cannot be more specific or tell you where you've gone wrong.

You've given us lots of detail elsewhere, but none of the stuff that relates to any VBA code which is where we feel the confusion is.
Dec 8 '09 #12

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

Similar topics

6
by: Steve Speirs | last post by:
Hi I'm trying to show/hide a simple piece of text and a text field on a form based on what choice is made from a drop down box. <select name="dropdown" size="1"> <option selected...
2
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic...
4
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by...
8
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". ...
5
by: suslikovich | last post by:
Hi everyone, I have a problem synchronizing two list boxes on a form. I want to display information in the second box based on the selection in the first box. First box (List0)lists all company...
4
by: coldfusionstudent | last post by:
i wish to show/appear and dissappear text box based on a the drop down item selected. what do i have to add? thanks under Comm_DEV drop down selection.
1
by: MarcGA | last post by:
MS Access 2003/Win XP. I have a small table of legal entities and tax ID numbers. This table is a source for a larger tax registration table. On the larger table, the legal entity is selected from a...
1
by: nithingujjar | last post by:
Hi, I need to to hide a field"addr_state1" based on a value in the drop down list field called "addr_country".i.e.,if addr_country.value=="in" then hide addr_state1 else , and if the value in the...
9
by: Brett_A | last post by:
I have a form where the first field is a dynamic drop-down that pulls from a db (Access). The fields associated with the query are task_id, task_name and task_rate. The field has the value of...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.