473,804 Members | 3,790 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Kitty001
3 New Member
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
4 1830
puppydogbuddy
1,923 Recognized Expert Top Contributor
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
3 New Member
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_F uel.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
3 New Member
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_F uel.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
1,923 Recognized Expert Top Contributor
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_F uel.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

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

Similar topics

8
2243
by: netsurfer | last post by:
Hi: Have a question on making the date automatically filled in by what the user enters in by the date at the top. The date entered at the top would most likely be on a Wednesday then I need to have all the prior dates pop in. Example: User enters 2/9/05 in the date field at the top being a Wednesday...I need the dates at the bottom to be filled in automatically, respectively as 2/3/05, 2/4/05, 2/5/05, 2/6/05, 2/7/05, 2/8/05, 2/9/05...
2
1425
by: Danny J. Lesandrini | last post by:
I searched Google but couldn't find any reference to this one, though I've observed the behavior before. The current case is where I select a value in a combo box, which has a Long Integer as it's bound value. After updating this value and moving to the next record, the field directly after the combo gets populated with the same value as the bound column of the combo. There is no code in the form putting this there. Any ideas?
2
2660
by: Phil Longworth | last post by:
Im very new to Access 97 and Im sure I should be able to do this but cant work out how. Im bulding a database for my stamp collection. I have two tables; one with details of all the individual stamps, and one with details of covers/envelopes the stamps are fixed to. Each indivdual stamp has a specific reference number (not an auto-number). Rather than manually enter the reference number into my 'covers/envelopes' table I want Access to...
2
1636
by: Cindi | last post by:
Hello again, I have a form that fills a text box with data according to the selection in the combo box. Two questions please: 1) The combo box does not have a control source so when opening the form, the combo box is empty but the text box already contains the first record. What do I need to do to either have both the combo box and text box empty on
1
1471
by: Paul Glavey | last post by:
Hello anyone any idea how to do this. The problem I am having has to do with Continuous Forms. In the header of the form I have 4 Combo boxes. For now lets just work on one combo box. The combo box name is 'PYID'. The table name is 'Invoice' and the field name is 'PYID' and that field is column 3. Thats if in access columns start at 0. OK What I want to do is this, when a user selects a value from PYID combo box in header it will be the...
1
2635
by: leiger | last post by:
Hi, I need help with this problem as soon as possible (within a couple of days). This is the first time I have ever used Access 2007 and therefore I am having some problems - especially as I am attempting some things I have never used in a database before this. As you can see in the picture, I need to create a form to edit pet details. I want to use a combo box to select the owner, then (if possible) have all of the records in the...
22
11347
by: Lewe22 | last post by:
I am creating a small Access db which performs a series of updates to a SQL database. The Access db consists of a ‘Main Form’, from which the user can run each update via a series of command buttons. Each update has been written as a SQL pass-through query. Example Update: UPDATE unit_instance_occurrences uio SET fes_active_places =
3
3008
by: evenlater | last post by:
Using Access 2007, I've found that combo box back colors change to transparent from normal inconsistently for no reason I can discern. Never had that problem in previous versions of Access. I do have the back style properties set to Normal and back colors set to white, but sometimes when I tab out of a particular combo box the back color changes to match the back color of the detail section. Has anybody else had this experience? Is there...
3
1833
by: wassimdaccache | last post by:
Dear I am working on office 2007. I was working on office 2003 I had a combo in the toolbar on access where I can find the control name of my record. For example if I have in a form many command name as below: Command1
0
9705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10568
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10323
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10311
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.