Combo box adds to text box

nightmaregenerator

Registered User.
Local time
Today, 11:18
Joined
Dec 11, 2009
Messages
33
I have a form that basically allows us to record where a driver went whether they did a return trip and how many kilometers they are charged for.

So basically what I can't seem to figure out is how to the kms to automatically come up when I select the destination.

It's basically set up with a table that has four columns with

From, To, Return and Kms.

In my form I have a combo box that allows you to select the the trip it was.
But what I need is for when I select the trip it automatically adds the kms traveled to the kms text box.

I know it's probably a really simple solution but I can't seem to figure it out.

Any ideas?
 
If I understand your question correctly, you send a driver off on a trip, on occasions the driver secures a return load, you are recording this outward bound trip and information relating to the return trip. In the same record.
I would suggest you may wish to consider the outward bound trip, and the return trip as two separate entities. It is possible that the mileage on the outward bound trip may be different mileage than the return trip, the destination for the return trip may not be back to the starting location.
 
The information supplied for the database does not specify the kms separately for each return load.

And because there are so many possibilities for destinations working out each leg can be difficult.
 
>>> But what I need is for when I select the trip it automatically adds the kms traveled to the kms text box.<<<

Your original question gives the impression that you already have the kilometres stored somewhere in a table, however your reply now gives the impression that you need to calculate the kilometres.

I created a database that calculates the “as the crow flies” mileage for Rivar (a UK Sand and Gravel Company), however to do this you need location data for the point of departure and the delivery address.

You may be able to find a web service that will provide you with the distance, however I suspect you may have to buy some data.

The alternative is to build up the data yourself. To do this get a large ordnance survey map of the area you cover, stick it to the wall, you will need a map with a grid system shown on it, then every time you add a new destination or departure point to your database also add to this new location the X and Y co-ordinates. From these you will be able to calculate the straight line distance between the departure point and destination. As a general rule of thumb (in the UK) you add 20% on to the “as the crow flies” distance to give you an approximation of the actual road mileage.

There are some "Open Source" map data resources available on the net, may be worth a look.
 
Sorry if I have confused you, I do have the data stored in another table with the departure destination, the to destination and the optional return trip destination with the kms stores in the next coloum so it looks something like this:

ID From To Return Kms
1 Brisbane Brookstead Sydney 1150

So what I want is when I select this trip in the drop down list I want in the separate kms field to automatically pick up it is 1150kms.

Hopefully this clarifies what I want. :D
 
With this said, is there anyway to refer to another field, then be able to use that refrence in a sum so if I wanted to create another field that times the load size (that refers with =[SingleDouble].[Column](2)) to the kms travels (=[Destination].[Column](4)) in an unbound control?

Or is this impossible, from what I have tried it just returns #Error
 
The video shows you how to extract individual column values from the combo box using the after update event of the combo box.
It appears to me that you have two combo boxes, one for the kilometres and one for the load size. I assume that both of these combo boxes use the after update event to transfer information into text boxes.
Now you require a third textbox to display a calculation based on the other to textboxes.

If this is the case then you need to decide which of the two combo boxes is Clicked On last, in that one, add some code to the after update event which adds the values from the text boxes together.
You need to add a third textbox let’s call it answer, the other two textboxes which are now filled with data from the relevant combo boxes, let’s call them textbox one and text box two, then in the after update event of the “last” combo box add a line of code similar to this:
txtBoxAnswer = txtBoxOne + txtBoxTwo
 
txtBoxAnswer = txtBoxOne + txtBoxTwo

Oh right yes, I even learnt that in school

I have used the code that was used in the video auto fill the text boxes but I found when the value was auto filled with a decimal place it didn't appear, is that becasue I need to declaire that it's not just a normal number but a decimal?

I have also found a problem, I continued to use this to work the gross and the allowance each person gets but the value always is deleted. Is there a way that it will keep the value?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom