using macro in form to convert XY coordinates

  • Thread starter Jose Ruben Gonzalez-Baird
  • Start date
J

Jose Ruben Gonzalez-Baird

I tried posting this earlier, but it doesn't look like it posted properly.
Sorry for any redundancy.

I am trying to create two buttons on a form in access that will convert XY
coordinate values. One will convert from decimal degrees (DD) to degrees
minutes seconds (DMS), the other will convert from DMS to DD.

There will be four fields on the form tied to a registration table: X_DD,
Y_DD, X_DMS & Y_DMS. The format of the DD entries will be (I'm thinking)
double (will single work?) with precision up to 6 decimal places. The format
of the DMS entries will be DDD MM SS.S (where D=degrees, M=minutes, and
S=Seconds, precise to one decimal place.

If a user enters XY data in either format I want each button to be able to
convert to the other format. Is a macro the best way to do this? I have a
fairly okay idea on how to goe from DMS to DD using the following code:

Dim Degrees as Double
Dim Minutes as Double
Dim Seconds as Double
Dim DMS as Variant
Dim DD as Double

DMS = Split([Latitude])
Degrees = CDbl(DMS(0))
Minutes = CDbl(DMS(1))
Seconds = CDbl(DMS(2))
DD = (Seconds/3600) + (Minutes/60)+ Degrees

but I'm not sure how to go back the other way and get the DMS into the
proper format. Also, i'm not sure how to actually get this code into the
macro itself--i understand how to open a mnew macro in design view and
specify a list of commands, but i don't know where i would execute this code
and how to tie it calcs to the field in my table. If anyone could help me it
would be greatly appreciated. Thanks, Ruben.
 
A

Allen Browne

Microsoft released a sample database named Neatcode.mdb years ago. It
included code for trig and great circle distances, as well as string
functions.

Here's a link to the old A95 version:
http://support.microsoft.com/kb/148402

There was an A97 one, but it must have been called something else. Post back
if you are not able to convert the A95 one.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

"Jose Ruben Gonzalez-Baird"
 

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