Simply within SSMS right click on the instance and hit STOP and
To start an instance if you are still in SSMS you can simply right click and hit start
Note if you stop a SQL Server instance from within SSMS AND then exit SSMS and try and go back in you will be denied as SSMS is unable to connect to a service that is not up and running.
In such a case to restart the instance you need to go to SQL server configuration manager and click on the instance and restart from there.
In Windows 8.1 you can get to config manager by using the search facility.
Windows 10 Alternative
Hit the search ring
type in services.msc
A new dialog should appea that will have Services(Local) with several columns – Name / Description / Status / StartupType
You want the Status to be Running
Use the mouse to highlight SQL Server (MSSQLServer) and then right click
Start
As part of the standard installation the sa login is disabled as default.
Clearly although this is a useful security feature it is a bit awkward if you are wanting to undertake certain tasks and as part of the installation this security feature is in no way obvious.
So what do you do to re-enable it?
Firstly log into SSMS under the machine windows login.
Go to the Security section of the server (not any of the databases) and expand the Logins branch. SA the system admin should be listed and if it is disabled it will have a small red down arrow next to it.
To re-enable highlight sa and right click
Select properties
Select Status
now alter the following
Permissions to connect to database engine
Set this to GRANT
Login
Set this to Enabled
Now highlight instance itself and right click and go to properties.
Within server properties highlight Security.
And change set server authentication to
SQL Server and Windows Authentication mode.
You should have sa login now enabled – don’t worry if sa still has a small red arrow next to it the SSMS client needs to be refreshed to see changes to set up.
If you want to change the password for the SSMS server I would recommend running the following.
ALTER LOGIN sa ENABLE ;
GO
ALTER LOGIN sa WITH PASSWORD = 'DifficultPass9£' ;
GO
Note you can enforce the requirement for a strong password within the same security section of the sa login if you require.
A while back I got the opportunity to work with a friend who times athletic races. After a bit of questioning he showed me some of his equipment and how it worked. I realised I could probably put together some home made timing software and so I set about doing it. The following is an overview of the stages that I went through to create the software.
Firstly its important to understand how the hardware works. To my mind this is very much a pattern and irrespective of the software you are using it is going to have to perform the same tasks in the same order.
Pre race test and hook up
Each competitor is given an RFID chip that has a unique number registered to it. (Numbers can be changed but requires specialist equipment)
A timing box is used to both power the matts (aka antennae) and act as a clock. When someone goes over the matt the chip emits the number and sends to the box. The box then places a time stamp on the chip and places in a file. A file or stream of all these strings is then pushed out of the timing box to awaiting computer.
Computer is listening and takes this information and software does the rest
In terms of the information that is produced by the box this is remakably simple – a raw hex string for each read.
My solution has three main tables
T1 – Raw times
T2 – Competitors
T3 – Chip Tag numbers.
The hard coded chip numbers are hex and each competitor is allocated a chip – they are actually being allocated this hex key but the number equates so on the chip itself will be a readable number eg 14001, 14002 the actual raw code from the box is often something like 45ab32c
What the software then does.
Step 1
Ensure exact duplicates reads are not entered generally because of multiple imports of same file.This is done by setting the full hex key as a primary key disallowing the same value to go into the Raw Times table multiple times.
Step 2
Hex to Decimal translation
Step 3
Drop times before race start time.
Simple select query.
Step 4
Match Reading to competitors – A simple join after hex to decimal translation of information from 3
Step 5
Sort times within competitor in ascending order
Data sort on dual columns
Step 6
Gate times – Competitors get multiple reads over the matt. I have set up something called a gate ( no idea whether this is a standard pattern or not but its what I call it ) Then a gate period is subjectively decided, lets say 30 seconds, (this can be altered for lapped races where you know a racer can’t complete a time in a certain time). A Query is then set up to look to the first time of a competitor and the gate period is added. The software continues looking down the times and deletes any times greater than the first gate time but less than the first gate time plus the gate period.
Step 7
Count timing points
In some races there are laps some are point to point – a lapped race can be thought of as recursive non lap race in that it is a series of non lap races where the end of one non lap race is the start of another. All times for each competitor are sorted in increasing order and an additional field is added with incremented numbers 1,2,3,4 etc. Typically there will be 2 a start and a finish. There can be one where a gun has gone off and competitors are not running across a start matt. In that instance everyone is considered as having the same start time the time of the Starting pistol and start one is given the 2 point and 1 is assumed to be a pre-set time.
Step 8
Pivot the times
Place point number as column header – name of competitor as row heading and time value as the value of the pivot.
Step 9
Calculate the lap times
Simple n+1 time minus n time
Step 10
Add up individual times to get total race time sort by any additional category eg gender age etc… sort time order and allocate prizes appropriately.
Step 11
Pick up whatever pretty report writer you can get your hands on – excel will do at a push and print out and hand to race organisers.
Step 12
Make pretty forms so you can easily change competitors add in extra times for missed times allow for edge cases like DNFs DQs penalties etc.
Sunday 11th of May I had the opportunity to test the software out by acting as lead timer on the Castle of Mey 10k the most northerly 10k in the country. Glad to say worked perfectly.
Below is a video of the 2015 race where we were in the McNicol Van
This code is generally available all over the tinternet nonetheless I list it here for my own personal use. I use an autoexec macro to trigger the code on open
With a Run Code action to trigger the AttachDSNLessTable…
So the code in the macro might look something like this
AttachDSNLessTable(“Table01Invoices”,”Table01Invoices”,”Server01″,”AccountingDatabase”,””,””)
Alternatively you could run it from the immediate window of the VBA module section.
Ctrl + G to get the immediate window up then create the function with the required parameters placing a question mark in front of the function eg
?AttachDSNLessTable(“Table01Invoices”,”Table01Invoices”,”Server01″,”AccountingDatabase”,””,””)
Pressing return will result in True result and when you go to the tables section Table01Invoices or your table should appear. Note if you have the tables section open of the database window then you will need to refresh.
Honestly works a treat and you can totally revolutionise processes if you are allowed to use the ease of front end design of something like MS Access with the scalability and power of SQL Server.
Needless to say vendors tend to be universally unwilling to give me details of their(/our!) backends.
'//Name : AttachDSNLessTable
'//Purpose : Create a linked table to SQL Server without using a DSN
'//Parameters
'// stLocalTableName:Name of the table
'// stRemoteTableName: Name of the table that you are linking to on the SQL Server database
'// stServer: Name of the SQL Server that you are linking to
'// stDatabase: Name of the SQL Server database that you are linking to
'// stUsername: Name of the SQL Server user who can connect to SQL Server, leave blank to use a Trusted Connection
'// stPassword: SQL Server user password
Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stServer As String, stDatabase As String, Optional stUsername As String, Optional stPassword As String)
On Error GoTo AttachDSNLessTable_Err
Dim td As TableDef
Dim stConnect As String
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
End If
Next
If Len(stUsername) = 0 Then
'//Use trusted authentication if stUsername is not supplied.
stConnect = "ODBC;DRIVER=SQL Server;SERVER=" & stServer & ";DATABASE=" & stDatabase & ";Trusted_Connection=Yes"
Else
stConnect = "ODBC;DRIVER=SQL Server;SERVER=" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword
End If
Set td = CurrentDb.CreateTableDef(stLocalTableName, dbAttachSavePWD, stRemoteTableName, stConnect)
CurrentDb.TableDefs.Append td
AttachDSNLessTable = True
Exit Function
AttachDSNLessTable_Err:
AttachDSNLessTable = False
MsgBox "AttachDSNLessTable encountered an unexpected error: " & Err.Description
End Function
Don’t get me wrong as a platform for communication I consider things like facebook and Linkedin as necessary evils for what is essentially cloud service market places but my preferences are always…
No adverts
No demands to have login prior to viewing site
As much annonymity for visitors as possible
Long form writing!!!!
I guess the thing that irks me the most is the light manipulation that occurs on these sites. They gently nudge you towards their wishes not your own. I must say as an exercise in communication I am much happier with this format where I have greater editorial control. (albeit a bit less traffic)
Its why I really love bespoke ( or as bespoke as possible ) if I could I would be designing my own operating systems.
Maybe one day.
Why?
2 words
Greater Understanding.
Leading to improvements in
1) Flexibility
2) Control
3) Ability to anticipate
4) Adaptibilty
5) Automate tasks ( Given time in certain cases I have been able to completely design out tasks )
6) Improved long term planning
7) Increased reliability
8) Faster response times
9) Reduce requirement for others time ( always something which is a complete premium )
10) Better timing
11) Massive coordination improvements ( yes why ask someone to tell you about something why not give them the ability to edit the information themselves – I can stay at home, kind of)
12) Improved motivation
It allows me to experiment which is when I learn the most and I think leads to the holy grail of increased productivty and reduced cost.
Want to increase the productivity of you and the people around you? Give them as much flexibility as possible and open up your design environment. I can’t see anything but advantages resulting from this both personally and for the organisation.
A good example of an organisation going bespoke with their web design …
At work we recently moved to a new building which has been adapted several times, some spaces have had multiple uses and multiple security level changes. The present use of rooms is different from the original design. As a result walking down the corridor requires a combination of pressing buttons, waiting for automatically opening doors or simple manual operation.
I can see new people coming down the corridor and people regularly get caught out by at least one door waiting for a manual door to open automatically or alternatively trying to manually open the automatic doors one set of which have heavy hydraulics.
I quite often put together various databases / applications to help me with my side projects. This is a good example. In an effort to help me remember my Russian verbs I put together a small database to assist in learning and remembering verbs.
One table consisting of
PKID
Memory Number
Russian Imperfecive Form
Russian Perfective Form
English Translation
Conjugation Type
Conjugation Class
Reflextion
Memory Aid
Page in Book
Works nicely in conjunction with the code that alters the keyboard mapping when going between cells (follow LINK for details). I am entering the list of verbs based on the popularity of use as listed here.
And I have field (Page in Book) listed so that I can relate back to my personal reference manual.
“The big silver book of Russian verbs 555 fully conjugated verbs in all Tenses” by Jack Franke – McGraw Hill – 2 nd edition
Here’s an image of the simple form that I put together only took half an hour. I use a left click AZ sorting right click ZA sorting on columns much like applications such as Outlook and ITunes the difference is my sorting tends to be a bit more intelligent in that I will generally sort on multiple columns. EG if I have a sort on a name field first name for example I will make the surname the secondary sort. I personally really dislike the double click as an event I think it is highly imprecise. The memory aid is some tricks I took from a Tony Buzan book. Future development will be ability to print out list and a further child table that will allow recording of related conjugations and yes the example screen shot shows that I still need to input some more information.
I eluded to it in my last post but when I have tabulated forms I like to have the labels activated and set to sort alphabetically ascending on left click and descending on a right click.
I use the mouse down event as trigger for this.
If Button = acLeftButton Then
Me.OrderBy = "Q001Contacts.CompanyName, Q001Contacts.Surname, Q001Contacts.Firstname"
Me.OrderByOn = True
Else
Me.OrderBy = "Q001Contacts.CompanyName DESC, Q001Contacts.Surname DESC, Q001Contacts.Firstname DESC"
Me.OrderByOn = True
End If
I use this pretty much on every single tabulated form that I have – This is not so different from Outlook or Itunes. What is different is that I tend to use a slightly more intelligent sort. In the above code you can probably see that for this particular column (its the company column) I first sort on company then I sort on the surname of the individual and then on the first name. I find it frustrating on things like Itunes or Outlook that you can be left searching around within a sort category sometimes as it is unclear what order within the sort that things are arranged by.
I use the left and right click rather than double because I used to find that double clicking would first sort the list one way and then immediately sort the other. A double click I believe sends mixed messages to the system and encourages lag. I still hate the idea of double clicking on things.
If I could change one thing about standard UI design it would be to get rid of the double click!!!
Needless to say I have banished double clicking from all my UIs.
The other day I had a good morning. A colleague had asked me to help him out on something and we’d just spent an hour going through some options getting pretty much nowhere, finally I told him I was out of ideas and we were going to have to leave it for just now. He thanked me but truthfully I wasn’t very happy. Things were broken and in this case broken was inoperable. I left his desk and started walking back to my office which is located in another buildings ten minutes away. Out of nowhere and almost exactly half way between both buildings I realised what the problem was. I immediately phoned my colleague and he made the required adjustments. Hey presto everything worked.
I love getting things working
and I love when you suddenly realise how to get things working.
Want to backup files and don’t have a fancy Database Administrator or sysadmin on 40k that knows his way around SQL Server 08R2 and MS Access , windows server and fully complies with continuous backup?
This might prove useful.
With any of the standard bespoke internally created applications that I am responsible for I like to have three main copies or parts.
1.a Back End
2.a Development copy front end – (this is used to adjust and create runtimes )
3.a Front end run time
Of the above two I backup both the back-end and the development copy of the front end. I do not back up run times (No.3), personally if I have the others backed up I can re-create a run-time from whatever point I desire. If for some reason I can’t create a run-time from a development copy it is time to roll back on the development copy – this should exist because of this very post.
In terms of the two types of copies I consider both equally important. Back-ends are easy to create but very difficult to re-create increasing in value with time. Front ends have no value in the data but take an extra ordinary amount of time to figure out and likewise are very awkward to recreate increasing in value with time. Both are digital and can be copied multiple times often with little to no cost (size dependent for back ends). Many front ends are actually tiny but their value comes from the way in which things flow and the speed with which they execute.
So I backup both to date I’ve had some brushes with almost disaster but never actually lost an application. Yes there have been hiccups mainly due to my own error – getting confused with versioning and deleting the most up to date version rather than yesterdays version. Forgetting a password on an encrypted USB and having it wipe itself requiring recovery from backup – that kind of thing annoying but not really a problem. I now have a daily backup routine that at least means that I cannot really loose more than a days work. I use it all the time.
Option Explicit
Dim FSO
Dim vardatefile
Dim varmonthfile
Dim BDayFilePath
Dim BMonthFilePath
Dim Varnow
Set FSO = CreateObject("Scripting.FileSystemObject")
Varnow = now
vardatefile = "YourDatabaseBackEndCopy-Weekday-" & day(varnow) & ".accdb"
varmonthfile = "YourDatabaseEndCopy-Month-" & Month(varnow) & ".accdb"
BDayFilePath = "C:\" & vardatefile
BMonthFilePath = "C:\" & varmonthfile
FSO.CopyFile "C:\DatabaseTarget.accdb", BDayFilePath, "True"
FSO.CopyFile "C:\DatabaseTarget.accdb", BMonthFilePath, "True"
Set FSO = nothing
msgbox "Backup Complete" ,0, "Backup Script"
Save in simple word editor and change to vbs suffix , double click to run.
Note I have made this Option Explicit which is good practice although it is entirely possible to remove Option explicit and dynamically set the variables.
UPDATE January 2021
Yes its still here and I still seem to be sporadically writing. Decided that I wanted to change the name to something more representative of what the site is about. So henceforth it is Cloudy DATA blog.
April 2014
This was my first post on 27 April 2014 as I write this I am about a month away from its 7th birthday.
I used to find configuration kind of frustrating – highly repetitive unintuitive and often changing as software versions change.
I now consider it a simple exercise in rote learning for which there is no solution except perseverance, patience and determination and I try to find out the names and numbers of the key administrators.
This change in perception means I no longer feel the kind of frustration I previously felt. I am also much more likely to refer to manuals than trying to guess my way through a menu system which was in retrospect the impatience of youth. As a result I am much more organised in documenting and keeping documentation and I think more productive as a result.
The amount of setups that are hindered by insufficient security privileges being available to the individual doing setup must amount to millions of lost hours. Please for those giving configuration tasks to individuals build in large amounts of time for configuration. If you don’t you’ll probably just be burnt.
Programming by comparison seems gloriously imaginative and logical. Makes me think that a fundamental reason why users hate changes in Operating Systems is because of configuration. They have to re-learn quite a few sets of obscure unintuitive procedures no matter how nice the UI is, they last sorted out X years ago when they bought their previous device. As for the XP, Win 7, Win 8 debate – personally I like Win 8.1, got it on my surface. Maybe because the configuration of Win 8.1 seems like a complete doddle to the kind of obscure software packages I normally have to deal with.
Important
Proviso : bear in mind that different Windows operating system versions have different support for languages – with Windows 7 you require ultimate version of the OS and then you have to ensure that the required language pack is installed – happy to say that Win 8 has language support as standard although you will need to specifically request certain regional input options within the settings. Windows 10 is similar, language support is free although it is likely you will have to specifically configure languages if there is more than one. My environment when I first solved this was Windows 7 ultimate.
So the problem – You are multi-lingual (or trying to be) and you regurlaly need to change mapping of your keyboard between alphabets (you can also touch type in both alphabets). You can do it manually everytime you need to change but it’s a pain, you have a database with fields some of which are in one language the others of which are in another language. You would like to alter keyboard mapping to specific languages on entering particular fields but how do you do it?
The following uses the Windows API to change the keyboard language globally. This can be done through VBA in MS Access no problem remembering the provisio that your OS must support your chosen language.
Firstly place the following in a module (note no end function required)
Public Declare Function ActivateKeyboardLayout Lib "user32.dll" (ByVal myLanguage As Long, Flag As Boolean) As Long 'define your desired keyboardlanguage
Then you can call the function from any form event.
Eg on field GotFocus and LostFocus
'1049 Russian keyboard language layout
'2057 English(United Kingdom)keyboard language layout
'1033 English (United States) keyboard language layout
Private Sub A_GotFocus()
Call ActivateKeyboardLayout(1049, 0)
End Sub
Private Sub A_LostFocus()
Call ActivateKeyboardLayout(2057, 0)
End Sub
One of the most useful and easy improvements I ever made to working was simply learning how to touch type. Its never been particularly necessary for programming as I find anytime I’m programming I write relatively little and the combination of tabs, weird characters, automatic code generation, intellisense and strange syntax results in a fairly uniform speed, touch typing or otherwise. No were it tends to be useful is simply for smashing out quick communications with individuals. If things are going well things tend to change quickly. Yes I need that no hang on things have changed cancel that have you got this? That kind of thing. This is were it helps to have a work colleague who is also a quick typist and a quick responder.
So I went out and bought what is called a mechanical keyboard from Das Keyboard (link to their site below) a name I might add was quickly noted as somewhat inaccurate. A colleague immediately pointing out that a mechanical keyboard really has no electronic parts whatsoever like the old key and lever ones you sometimes see in old black and white films.
I settled on a the S Ultimate model which has no labels on the keys. I figured hey I’ve started a bit of Russian if you change the key mapping to cyrillics any letters are useless anyway so lets go hard core. It arrived at my work and female colleague no 1 enjoyed watching me eagerly unpack and plug it in. Now I thought I was a touch typist. Turns out that wasn’t quite true. To register the keyboard I had to re-start the OS. Fine except I immediately had to re-enter my password to get to desktop. Three times later I had to phone support to unblock my password. Yep you guessed it I wasn’t quite the Ninja touch type artist I had fully convinced myself I was.
I’m down with it now but it did require me upping my game. I am particularly careful using some of the USB sticks as those that are encrypted have a three strikes and your out policy with NO recovery – that did slightly concern me.
So what is it like as a keyboard.
I was immediately about 4% faster I have raised my average speed from about 59 words per minute to something like 66 words per minute. On the rare occasion that I don’t make any typing mistakes I can get up to 75. Think of the discipline some must have had to use the old mechanical keyboards I’m sure that the requirement to use typex would have concentrated the mind on not making mistakes.
It makes me think that maybe Das Keyboard should do a special keyboard with the option for electrifying the delete key.
Its 2021 and I originall wrote this article back in 2014 – It sounded on a reread just plain wrong so.
I still maintain that programs should be in some way immortal and maybe wordpress is a case in point. I’ve updated and changed my blog and it runs today better than it ever did. Yes wordpress may change and there is a requirement that it should be updated but how long could it be maintained without maintenance.. Quite probably for a time close to forever.
Some years back we hired a young lad by the name of Iain Brodie on a temporary contract – The week before I had been at an ESRI conference which had extensively discussed Web Mapping and a speaker had demonstrated showing points in Google Maps. It was clear to me that the Google Maps url would accept and zoom to coordinates if those coordinates passed to it were Longitude and Latitude. Where I work there are significant numbers of datasets that use old Ordnance Survey UK specific Eastings and Northings coordinate system. Ordnance Survey actually set out the mathematics of conversion to Lat and Long on this page even detailing coded functions albeit in Javascript.
I specifically wanted to dynamically convert using Visual Basic for applications (specifically from MS Access). When Iain arrived it was clear that he was useful with computers and so I tasked him with finding VBA code from the internet. Between us we managed to get it working and I still regularly use the function set today to give users of applications a map in Google Maps. It really is a very nice quick tool that gives users quick access to maps for – you bet zero cost. My favourite price. We originally had it working with Google Earth but I only use it with Google Maps now.
Function PHId(North1, N0, aFo, PHI0, n, bFo)
PHI1 = ((North1 - N0) / aFo) + PHI0
M = Marc(bFo, n, PHI0, PHI1)
PHI2 = ((North1 - N0 - M) / aFo) + PHI1
Do While Abs(North1 - N0 - M) > 0.00001
PHI2 = ((North1 - N0 - M) / aFo) + PHI1
M = Marc(bFo, n, PHI0, PHI2)
PHI1 = PHI2
Loop
PHId = PHI2
End Function
Function Marc(bFo, n, P1, P2)
Marc = bFo * (((1 + n + ((5 / 4) * (n ^ 2)) + ((5 / 4) * (n ^ 3))) * (P2 - P1)) - (((3 * n) + (3 * (n ^ 2)) + ((21 / 8) * (n ^ 3))) * (Sin(P2 - P1)) * (Cos(P2 + P1))) + ((((15 / 8) * (n ^ 2)) + ((15 / 8) * (n ^ 3))) * (Sin(2 * (P2 - P1))) * (Cos(2 * (P2 + P1)))) - (((35 / 24) * (n ^ 3)) * (Sin(3 * (P2 - P1))) * (Cos(3 * (P2 + P1)))))
End Function
Function lon(East1, North1)
a = 6377563.396
b = 6356256.91
F0 = 0.9996012717
E0 = 400000
N0 = -100000
PHI0 = 0.855211333
LAM0 = -0.034906585
aFo = a * F0
bFo = b * F0
e2 = (aFo ^ 2 - bFo ^ 2) / aFo ^ 2
n = (aFo - bFo) / (aFo + bFo)
InitPHI = PHId(North1, N0, aFo, PHI0, n, bFo)
nuPL = aFo / ((1 - (e2 * (Sin(InitPHI)) ^ 2)) ^ 0.5)
rhoPL = (nuPL * (1 - e2)) / (1 - (e2 * (Sin(InitPHI)) ^ 2))
eta2PL = (nuPL / rhoPL) - 1
M = Marc(bFo, n, PHI0, InitPHI)
Et = East1 - E0
X = ((Cos(InitPHI)) ^ -1) / nuPL
XI = (((Cos(InitPHI)) ^ -1) / (6 * nuPL ^ 3)) * ((nuPL / rhoPL) + (2 * ((Tan(InitPHI)) ^ 2)))
XII = (((Cos(InitPHI)) ^ -1) / (120 * nuPL ^ 5)) * (5 + (28 * ((Tan(InitPHI)) ^ 2)) + (24 * ((Tan(InitPHI)) ^ 4)))
XIIA = (((Cos(InitPHI)) ^ -1) / (5040 * nuPL ^ 7)) * (61 + (662 * ((Tan(InitPHI)) ^ 2)) + (1320 * ((Tan(InitPHI)) ^ 4)) + (720 * ((Tan(InitPHI)) ^ 6)))
lon = (LAM0 + (Et * X) - ((Et ^ 3) * XI) + ((Et ^ 5) * XII) - ((Et ^ 7) * XIIA))
End Function
Function lat(East1, North1)
a = 6377563.396
b = 6356256.91
F0 = 0.9996012717
E0 = 400000
N0 = -100000
PHI0 = 0.855211333
LAM0 = -0.034906585
aFo = a * F0
bFo = b * F0
e2 = (aFo ^ 2 - bFo ^ 2) / aFo ^ 2
n = (aFo - bFo) / (aFo + bFo)
InitPHI = PHId(North1, N0, aFo, PHI0, n, bFo)
nuPL = aFo / ((1 - (e2 * (Sin(InitPHI)) ^ 2)) ^ 0.5)
rhoPL = (nuPL * (1 - e2)) / (1 - (e2 * (Sin(InitPHI)) ^ 2))
eta2PL = (nuPL / rhoPL) - 1
M = Marc(bFo, n, PHI0, InitPHI)
Et = East1 - E0
VII = (Tan(InitPHI)) / (2 * nuPL * rhoPL)
VIII = ((Tan(InitPHI)) / (24 * rhoPL * nuPL ^ 3)) * (5 + (3 * ((Tan(InitPHI)) ^ 2)) + eta2PL - (9 * ((Tan(InitPHI)) ^ 2) * eta2PL))
IX = ((Tan(InitPHI)) / (720 * rhoPL * nuPL ^ 5)) * (61 + (90 * ((Tan(InitPHI)) ^ 2)) + (45 * ((Tan(InitPHI)) ^ 4)))
lat = (InitPHI - ((Et ^ 2) * VII) + ((Et ^ 4) * VIII) - ((Et ^ 6) * IX))
End Function
Function degrees(radians)
degrees = 180 * radians / 3.14159265358979
End Function
Function trunc(value)
If value > 0 Then
trunc = Int(value)
Else
trunc = Int(value + 1)
End If
End Function
And here is the code the onclick function of a button called Command01 and it pulls from a screen that has an eastings and northings field on it and which has a Sitename field.
Dim Llatitude As Double
Dim Llongitude As Double
Dim strSitename As String
Llatitude = degrees(lat([Eastings], [Northings]))
Llongitude = degrees(lon([Eastings], [Northings])) - 0.0015
strSitename = Me.Sitename
Dim strlatlong As String
strlatlong = Llatitude & ",+" & Llongitude
‘Here I have two options – the first places a marker on the map – as far as I can tell – the marker is only available within google with the side panel displayed as well. The second shows the map centered on the requested location but without any markers. Choose one
Google recently slightly altered their URL to link to Google Maps. This code passes eastings and northings from fields into a function that calculates Longitude and Latitude and then passes those calculated coordinates to the google maps url for display
Note you will need to have implemented the functions that calculate lat and long for this to be useful.
Private Sub Command01_Click()
On Error GoTo Err_Command01_Click
Dim Llatitude As Double
Dim Llongitude As Double
Dim strSitename As String
Llatitude = degrees(lat([Eastings], [Northings]))
Llongitude = degrees(lon([Eastings], [Northings])) - 0.0015
strSitename = Me.Sitename
Dim strlatlong As String
strlatlong = Llatitude & ",+" & Llongitude
'From 24 March Google changed their hyperlink address this is the new one
Command01.HyperlinkAddress = "https://maps.google.com/maps?q=" & strlatlong & "+(" & strSitename & ")&z=18&iwloc=near&hl=en&ll=" & strlatlong
Exit_Command01_Click:
Exit Sub
Err_Command01_Click:
MsgBox Err.Description
Resume Exit_Command01_Click
End Sub