Sometimes all it takes is a walk

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.

Rolling VBS Script

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.

In the beginning

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.

Configuration vs Programming

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.

VBA Function to allow alteration of Key Mapping for Multi-lingual support

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

You can find the LCID decimal codes here
Microsoft Windows Location Identifier Codes LCID

Wax on Wax off

IMGP0087
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.

http://www.daskeyboard.com/model-s-ultimate/

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.

I am writing a letter now.