Hello,
I am trying to use a function I wrote to convert latitude and longitude from decimal to degrees/minutes/seconds (DMS). The function shows up in the Expression Builder under the "Built-in Functions" folder. The data is stored as type double in a table called Scenarios. I want to pass the field value to the function, convert from decimal to DMS (which is a string) and return the DMS string to extract the right 2 decimals from the seconds.
When I run the query, I get the following error message:
"Undefined function 'Dec_to_DMS' in expression"
Any help would be greatly appreciated.
The expression in the Expression Builder is:
Here is the function I am using:
I am trying to use a function I wrote to convert latitude and longitude from decimal to degrees/minutes/seconds (DMS). The function shows up in the Expression Builder under the "Built-in Functions" folder. The data is stored as type double in a table called Scenarios. I want to pass the field value to the function, convert from decimal to DMS (which is a string) and return the DMS string to extract the right 2 decimals from the seconds.
When I run the query, I get the following error message:
"Undefined function 'Dec_to_DMS' in expression"
Any help would be greatly appreciated.
The expression in the Expression Builder is:
PHP:
Lat_DMS: Dec_to_DMS([Scenarios]![Latitude])
Here is the function I am using:
PHP:
Public Function Dec_to_DMS(dblCoord As Variant)
Dim strDMS As String
Dim dblDeg As Double
Dim dblMin As Double
Dim dblSec As Double
Dim arrSplit() As Variant
strDec = Int(strCoord)
'get decimal min
arrSplit = Split(dblCoord, ".")
dblMin = Int(arrSplit(1) * 60)
'get decimal seconds
arrSplit = Split(dblMinute, ".")
dblSec = Round(arrSplit(1) * 60, 3)
'get hemisphere
If dblCoord < 0 Then 'neg so South or West
strDMS = "-" & dblDeg & " " & dblMin & " " & dblSec
Else 'pos so North or East
strDMS = Str(dblDeg) & " " & Str(dblMin) & " " & Str(dblSec)
End If
dblCoord = strDMS
End Function