PC Review


Reply
Thread Tools Rate Thread

converting decimal degrees to degrees, minutes, seconds

 
 
=?Utf-8?B?RGF2ZU4=?=
Guest
Posts: n/a
 
      26th Jul 2005
Is there a way in MS Access to input decimal degrees and have it convert to
degrees minutes seconds. Expression builder doesn't like any of the variation
I have tried. Can it be done in Expression builder, as a macro, or is there
another way to do it.

Thanks
Dave

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QnJpYW4=?=
Guest
Posts: n/a
 
      26th Jul 2005
That would be nice, but I think you may have to write a function that
converts for you (and probably represent it as a string). Here is one way, as
an example. I just sent the output to message boxes, both as literals and
using the degree/minute/second symbols:

Dim DecDeg As Double
Dim DecMin As Double
Dim Deg As Integer
Dim Min As Integer
Dim Sec As Integer
Dim DMS As String
DecDeg = InputBox("Enter degrees.")
Deg = Int(DecDeg)
DecMin = (DecDeg - Deg) * 60
Min = Int(DecMin)
Sec = Round((DecMin - Min) * 60, 0)
DMS = Str(Deg) & " degrees " & Str(Min) & " minutes " & Str(Sec) & " seconds"
Msgbox "Literals: " & DMS
DMS = Str(Deg) & Chr(186) & " " & Str(Min) & "' " & Str(Sec) & """"
Msgbox "Symbols: " & DMS

"DaveN" wrote:

> Is there a way in MS Access to input decimal degrees and have it convert to
> degrees minutes seconds. Expression builder doesn't like any of the variation
> I have tried. Can it be done in Expression builder, as a macro, or is there
> another way to do it.
>
> Thanks
> Dave
>

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGF2ZU4=?=
Guest
Posts: n/a
 
      26th Jul 2005
Thanks Brian, that works, but now how do I get it to populate the table field
"Latitude", with the converted data?

"Brian" wrote:

> That would be nice, but I think you may have to write a function that
> converts for you (and probably represent it as a string). Here is one way, as
> an example. I just sent the output to message boxes, both as literals and
> using the degree/minute/second symbols:
>
> Dim DecDeg As Double
> Dim DecMin As Double
> Dim Deg As Integer
> Dim Min As Integer
> Dim Sec As Integer
> Dim DMS As String
> DecDeg = InputBox("Enter degrees.")
> Deg = Int(DecDeg)
> DecMin = (DecDeg - Deg) * 60
> Min = Int(DecMin)
> Sec = Round((DecMin - Min) * 60, 0)
> DMS = Str(Deg) & " degrees " & Str(Min) & " minutes " & Str(Sec) & " seconds"
> Msgbox "Literals: " & DMS
> DMS = Str(Deg) & Chr(186) & " " & Str(Min) & "' " & Str(Sec) & """"
> Msgbox "Symbols: " & DMS
>
> "DaveN" wrote:
>
> > Is there a way in MS Access to input decimal degrees and have it convert to
> > degrees minutes seconds. Expression builder doesn't like any of the variation
> > I have tried. Can it be done in Expression builder, as a macro, or is there
> > another way to do it.
> >
> > Thanks
> > Dave
> >

 
Reply With Quote
 
=?Utf-8?B?QnJpYW4=?=
Guest
Posts: n/a
 
      26th Jul 2005
I can think of a couple of approaches. The first will store the information
as numbers, while the second will store the information as the resulting text
string:

For either of them, create a module with this public function in it:

Function DegreeConv(DecDeg As Double) As String
Dim Deg As Integer
Dim DecMin As Double
Dim Min As Integer
Dim Sec As Integer
Deg = Int(DecDeg)
DecMin = (DecDeg - Deg) * 60
Min = Int(DecMin)
Sec = Round((DecMin - Min) * 60, 0)
DegreeConv = Str(Deg) & Chr(186) & " " & Str(Min) & "' " & Str(Sec) & """"
End Function

1. Just store the decimal degrees and have the function run when you want to
see one of them in the proper format (e.g. when displaying on a form or in a
report), since I do not believe that there is a standard format for storing
angles or lat/long values. If you have a form that has two boxes: DecDeg and
Latitude, this code will correctly populate Latitude from the DecDeg.

Private DecDeg_AfterUpdate()
Latitude = DegreeConv(DecDeg)
End Sub

2. Store the resulting text string. To do this one, I started with a VERY
simple table called Degrees. It has only two fields: DecDeg (Number, Double)
and Latitude (Text). Create a few records with entries in DecDeg but leave
Latitude blank.

Now create a new query, go to SQL view, and past this into it:

UPDATE Degrees SET Degrees.Latitude= DegreeConv([DecDeg]);

When you run the query, it will update the latitude field to match the
decimal degrees.

The only drawback is that the data is stored as a string, not as a number.
You may wish to store both, as in my simple example, so that you can use the
numeric value in calculations, but the latitude string when displayed for
users.

"DaveN" wrote:

> Thanks Brian, that works, but now how do I get it to populate the table field
> "Latitude", with the converted data?
>
> "Brian" wrote:
>
> > That would be nice, but I think you may have to write a function that
> > converts for you (and probably represent it as a string). Here is one way, as
> > an example. I just sent the output to message boxes, both as literals and
> > using the degree/minute/second symbols:
> >
> > Dim DecDeg As Double
> > Dim DecMin As Double
> > Dim Deg As Integer
> > Dim Min As Integer
> > Dim Sec As Integer
> > Dim DMS As String
> > DecDeg = InputBox("Enter degrees.")
> > Deg = Int(DecDeg)
> > DecMin = (DecDeg - Deg) * 60
> > Min = Int(DecMin)
> > Sec = Round((DecMin - Min) * 60, 0)
> > DMS = Str(Deg) & " degrees " & Str(Min) & " minutes " & Str(Sec) & " seconds"
> > Msgbox "Literals: " & DMS
> > DMS = Str(Deg) & Chr(186) & " " & Str(Min) & "' " & Str(Sec) & """"
> > Msgbox "Symbols: " & DMS
> >
> > "DaveN" wrote:
> >
> > > Is there a way in MS Access to input decimal degrees and have it convert to
> > > degrees minutes seconds. Expression builder doesn't like any of the variation
> > > I have tried. Can it be done in Expression builder, as a macro, or is there
> > > another way to do it.
> > >
> > > Thanks
> > > Dave
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Decimal Degrees to Degrees/Minutes/Seconds Larry_Klotz Microsoft Excel Worksheet Functions 1 2nd Nov 2009 08:22 PM
Converting Degrees/Minutes/Seconds to Decimal Degrees ankud1@yahoo.com Microsoft Excel Programming 6 12th May 2007 05:28 PM
how can i convert degrees/minutes/seconds to decimal degrees? =?Utf-8?B?Q2hyaXNzeQ==?= Microsoft Excel Misc 2 28th Apr 2006 12:14 PM
convert decimal degrees to degrees minutes seconds =?Utf-8?B?Q2hyaXMgcg==?= Microsoft Excel Misc 2 6th Dec 2005 11:40 PM
How can I convert degrees minutes seconds to decimal degrees =?Utf-8?B?SGVpZGk=?= Microsoft Excel Worksheet Functions 1 23rd Sep 2004 02:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:17 AM.