By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 733 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

Automatically fills in a Value dependant on a Combo Box in a Form - Access 2007

Kitty001
P: 3
Hi Guys
I am new to MS Access and using MS Access2007.
I have been fooling around with Access trying to solve this problem for weeks but i just cant seem to chack it and I need some help.

I have a database based on the machines used for the maintenance of a golf course here in South Africa.
I have tables containing the "Groups of Machines", "Machines" and the "Types of Fuel" they use with Prices per Lt.

I have created a form thats been working fine but theres still a few things i need it to do for me and would appriciate all the help i can get.

In the Form I have 2 combo boxes
-GroupID
-Machines

In "GroupID" you choos the Group Of Machine that the "Machine" falls under and in Machines you choos the specific machine. Which works perfectly.
ie. GroupID: Fairways
Machines: S14 (Machine Code)

Then i have another combo box where you can choos what type of fuel was used.
ie. Petrol, Diesel,Oil, Hydrauic Oil,ect.

Now what i want it to do is when i choos a value from the "Fuel" combobox i would like the price per Lt to automatically apear in the Price field.
Now to the feeling i have it probably have something to do with the AfterUpdate Event in the Property sheet

I would have attached a image of the form but i have no idea as to how i do that

Thanks A million
Kitty//*
Oct 7 '08 #1
Share this Question
Share on Google+
4 Replies


puppydogbuddy
Expert 100+
P: 1,923
Try something like as shown below (replace the object names I used with their actual names in your application. Also, I am assuming that the price is in the 3rd column of your combobox. Keep in mind that column indexes start at 0 in ms access, so the third column will have an index of 2. Finally, I have assumed that txtPricePerLt is a textbox control on your form to display the price.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboFuelType_AfterUpdate()
  2.  
  3. txtPricePerLt = Me!cboFuelType.Column(2)
  4. ' Me.Requery        this line commented out......reactivate if needed.
  5.  
  6. End Sub
Oct 8 '08 #2

Kitty001
P: 3
Hi
Thanks for the quick reply but im i bat lost with the Index Parts. x_x

and also i dont understand the "Column" in the following statement.
txtPrice_per_Lt = Me!cboType_of_Fuel.Column(2)

Im trying my best to study VBA my own time, So i can understand a bit more.

ps..
My Price per Lt Control in the form is a Currency box as there has to be a Price with the south african Rand Value in.
Oct 10 '08 #3

Kitty001
P: 3
Hi
Thanks for the quick reply but im i bat lost with the Index Parts. x_x

and also i dont understand the "Column" in the following statement.
txtPrice_per_Lt = Me!cboType_of_Fuel.Column(2)

Im trying my best to study VBA my own time, So i can understand a bit more.

ps..
My Price per Lt Control in the form is a Currency box as there has to be a Price with the south african Rand Value in.
Oct 10 '08 #4

puppydogbuddy
Expert 100+
P: 1,923
Hi
Thanks for the quick reply but im i bat lost with the Index Parts. x_x

and also i dont understand the "Column" in the following statement.
txtPrice_per_Lt = Me!cboType_of_Fuel.Column(2)

Im trying my best to study VBA my own time, So i can understand a bit more.

ps..
My Price per Lt Control in the form is a Currency box as there has to be a Price with the south african Rand Value in.
The columns and column indexes refer to the columns of data in your combobox. In Access, you can refer to the individual columns by their column index.

I recommend you take the free tutorial(s) at the following link to answer your general questions. This site is one of the best free tutorial sites on the web. If you still need help with specific questions after doing the tutorial(s), then post back here.

http://www.fontstuff.com/access/acctut10.htm
Oct 11 '08 #5

Post your reply

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