Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Jun 2002
    Location
    Kansas
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Convert Degrees, Prefix with 0 (access 2000)

    I must convert Degrees Decimal to Degree Minute Seconds. Got that to work, but ... I must also have three digits in the Longitude value, or the points won't plot. Is there some way to ensure that my degree field is always three digits, even it it's 098 or 021?

    The snippit that does my conversion: Long-Deg: Int(Abs([Old.Longitude])), where Long-Deg is the name of the new field containng only the degree value, Old.Longitude is the decimal value in xxx.xxxxx format.

    Suggestions?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Convert Degrees, Prefix with 0 (access 2000)

    Good heavens! This reminds me of a photogrammetry app I overhauled in my last job. Are you entering the lat/lon values or capturing them with a digitizer? You could store your lat and lon values as text if you want to store the leading zeroes. If you're entering them, use an input mask to force zeroes in to left pad the value. You can convert the text to values easily enough when you make calculations. If you're passing the data back out to something like a GPS setup, you'll be giving them a text file anyhow won't you?
    Charlotte

  3. #3
    New Lounger
    Join Date
    Jun 2002
    Location
    Kansas
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert Degrees, Prefix with 0 (access 2000)

    Actually, I am starting with a text file that contains lat/long in Decimal Degree format. My Map Program requires Degree Minute Second format, and fails if the Degree portion does not contain 2 and 3 digits (Lat 99, Long 999). The conversion I use does not provide for leading zeros, and I don't know how to "pad" those with only two digits with a prefix of 0. The file, when transferred into the map program is pure text and I suppose one could write a script to add the extra zero, but seems to me that a more elegant way would be to stuff that 0 during the conversion, or maybe in the output of a report as a means of creating the text file. The best solution would be to use a map program that can read DD and not just DMS. Your thoughts are welcome - since there are more than 70K records, this is not a trivial "do by hand" task.
    Steve Gerecke

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Convert Degrees, Prefix with 0 (access 2000)

    Using the Format function, as Jon suggested, will store the value as text and left pad the zeros. For example, Format$(12,"000") gives you "012". Does that help?
    Charlotte

  5. #5
    New Lounger
    Join Date
    Jun 2002
    Location
    Kansas
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert Degrees, Prefix with 0 (access 2000)

    Works great - thanks a bunch!

  6. #6
    New Lounger
    Join Date
    Jun 2002
    Location
    Kansas
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert Degrees, Prefix with 0 (access 2000)

    Spoke too soon. While the format functions properly in the query, when I bring the converted values into the report (=[Lat-Deg]&"-"&[Lat-Min]&"."&[Lat-Sec]&"N "&[Long-Deg]&"-"&[Long-Min]&"."&[Long-Sec]&"W" ) the format reverts to whatever the calculated number is. IE 98 is 098 in the query, but is 98 in the report. This would represent the [Long-Deg] value.

    Perhaps there is a better way? I need to create only a text file that contains the field Label and the field value, like this: "Lat-Long: 34.56.22N 085.34.12W" - can I do this from the query, skipping the report? I don't need fancy formatting (font, color, bold etc), just Label and Value.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Convert Degrees, Prefix with 0 (access 2000)

    You can create a calculated field in a query:

    Output: "Lat-Long: " & Format([Lat-Deg], "00") & "." & Format([Lat-Min], "00") & "." & Format([Lat-Sec], "00") & "N "& Format([Long-Deg], "000") & "." & Format([Long-Min], "00") & "." & Format([Long-Sec], "00") & "W"

  8. #8
    New Lounger
    Join Date
    Jun 2002
    Location
    Kansas
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert Degrees, Prefix with 0 (access 2000)

    Yes... works great. My thanks to you all (Charlotte, Jon, HansV) for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •