Let user choose to see distances in miles or km

J

James Minns

Hi all,

I have the following problem: In a database which is already running, lots
of tables, lots of queries and forms, I need to allow the user to choose the
units in which distances are measured. At the moment the distances are in
miles.

It seemed that the most painless way to do this was to rename the data
tables, make a query with the same name as the original table and multiply
the distance fields by 1 or 1.61 to get miles or km to show to the user

This does not work because the query expression is not updateable and the
user has to modify the distances (which will always be stored in miles but
may be shown in km) :-/

So what might be the most pain-free way to add this logic? Thanks for any
help,

James
 
J

John Spencer

If you are showing the data to the user on a form, just add a control on the
form to show the miles converted to kilometers. The control source would be
something like
=[Miles] * 1.609344

Do the same thing in a query for a report. If you want to only show
kilometers and are not worried about data entry then you can show/hide the
relevant two control depending on the what the user wants to see. In that
case, you could stack the two controls on top of each other.
 
J

James Minns

Thanks for the reply,
I thought about that, but multiplying the distance in the control has the
same drawback as multiplying in a query - the resulting field on the form is
not updateable.

I need to be able to update the underlying value no matter what units are
chosen, but miles are always stored in the table. Data entry is necessary,
as is modification of existing data.

James

John Spencer said:
If you are showing the data to the user on a form, just add a control on
the form to show the miles converted to kilometers. The control source
would be something like
=[Miles] * 1.609344

Do the same thing in a query for a report. If you want to only show
kilometers and are not worried about data entry then you can show/hide the
relevant two control depending on the what the user wants to see. In that
case, you could stack the two controls on top of each other.


James Minns said:
Hi all,

I have the following problem: In a database which is already running,
lots of tables, lots of queries and forms, I need to allow the user to
choose the units in which distances are measured. At the moment the
distances are in miles.

It seemed that the most painless way to do this was to rename the data
tables, make a query with the same name as the original table and
multiply the distance fields by 1 or 1.61 to get miles or km to show to
the user

This does not work because the query expression is not updateable and the
user has to modify the distances (which will always be stored in miles
but may be shown in km) :-/

So what might be the most pain-free way to add this logic? Thanks for
any help,

James
 
J

John Spencer

Then you need two controls on the form and you will have to handle all the
conversions on the form.

On a single form use an unbound control that you populate using the current
event of the form. The user can enter Kilometers or miles depending on how you
set it up. You can have the values in the query - calculated kilometers and
actual miles.

When the the control loses focus, you can check the value in the control against
the value in the query and if it has changed you can update the field.


If this is a continuous form, then you will need to stack controls on top of
each other one to show the value and another unbound one for data entry. When
the display control gets the focus (it should be on top), set the focus to the
entry control and let the user enter the data. Then when the entry control
loses focus compare the value in the entry control and if it is different from
the stored value update the field value.



James said:
Thanks for the reply,
I thought about that, but multiplying the distance in the control has the
same drawback as multiplying in a query - the resulting field on the form is
not updateable.

I need to be able to update the underlying value no matter what units are
chosen, but miles are always stored in the table. Data entry is necessary,
as is modification of existing data.

James

John Spencer said:
If you are showing the data to the user on a form, just add a control on
the form to show the miles converted to kilometers. The control source
would be something like
=[Miles] * 1.609344

Do the same thing in a query for a report. If you want to only show
kilometers and are not worried about data entry then you can show/hide the
relevant two control depending on the what the user wants to see. In that
case, you could stack the two controls on top of each other.


James Minns said:
Hi all,

I have the following problem: In a database which is already running,
lots of tables, lots of queries and forms, I need to allow the user to
choose the units in which distances are measured. At the moment the
distances are in miles.

It seemed that the most painless way to do this was to rename the data
tables, make a query with the same name as the original table and
multiply the distance fields by 1 or 1.61 to get miles or km to show to
the user

This does not work because the query expression is not updateable and the
user has to modify the distances (which will always be stored in miles
but may be shown in km) :-/

So what might be the most pain-free way to add this logic? Thanks for
any help,

James
 
J

James Minns

John Spencer said:
Then you need two controls on the form and you will have to handle all the
conversions on the form.

Thanks for the info; though with all the forms in the db, its going to be a
long job to convert the program!
James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top