Wednesday, June 16, 2010

Microsoft Access: Datatypes and Switch vs Iff program flow statements

I think this may be the most obscure blog post I’ve ever written. I only write it because, even after I knew the answer, I couldn’t find this documented anywhere. Perhaps this will help someone searching for an answer someday.

I’ve tested this in Access 2003, but not Access 2007 (a disastrous upgrade btw).

If you’re actually reading this, you are using Microsoft Access and you have been using the "Switch” “Program Flow Built-In Function”. This is a unique to Access hack that allows one to mix a bit of programming logic into a query. In the pile of hacks that make up Microsoft Access this one’s a bit of a gem. You can mangle quite a bit of data with it. I believe it is a call out to Access Basic.

You used the Switch statement with a numeric data type. When you were done you attempted to do something with the result, such as a Join on another numeric. You then saw a “Type mismatch in expression.” error message.

It’s not documented in Access, but the Switch statement forces the result to be a string. If you don’t want to change data types to a string you should use nested IIF statements in place of the Switch statement.

You can also wrap the Switch statement in another function that casts the string to a numeric value.

That is all.

PS.

As long as you’ve read this far, here are some of my personal notes on the Switch statement…

Access has 3 Program Flow built-in functions: Choose, IIf and Switch. I use IIf and Switch.

These are taken from Access Basic. They can be used in Access Basic functions, or they can be used as functions in a column name (where I use them).

Switch has the advantage that it can handle multiple conditions cleanly, and include an error statement. It is poorly documented (see below) [1]. It can be difficult to construct a complex Switch in the Access editor or function wizard, it's better to construct it in a text editor and paste it in.

Switch can use the True and False operators. So if you want to have an error result used when all matches fail, you set "expr-n" to the operator "True" (no quotes). You might think  you should put the most common condition first to reduce execution time, but Switch always evaluates all the expressions.

Example of use of Switch (in this case the test would never be reached, Null and Not Null covers all branches):

SNAP_LOCAL_CONCEPT_TYPE: Switch([RESULT_UNITS] Is Null,"NumericObservationWithoutUnits",[RESULT_UNITS] Is Not Null,"NumericObservationWithUnits",True,"ERROR: IMPOSSIBLE")

[1] From Access Help ...

Evaluates a list of expressions and returns a Variant value or an expression associated with the first expression in the list that is True.

Switch(expr-1, value-1[, expr-2, value-2 … [, expr-n,value-n]])

The Switch function syntax has these parts:

Part Description
expr Required. Variant expression you want to evaluate.
value Required. Value or expression to be returned if the corresponding expression is True.

The Switch function argument list consists of pairs of expressions and values. The expressions are evaluated from left to right, and the value associated with the first expression to evaluate to True is returned. If the parts aren't properly paired, a run-time error occurs. For example, if expr-1 is True, Switch returns value-1. If expr-1 is False, but expr-2 is True, Switch returns value-2, and so on.

Switch returns a Null value if:

  • None of the expressions is True.
  • The first True expression has a corresponding value that is Null.

Switch evaluates all of the expressions, even though it returns only one of them. For this reason, you should watch for undesirable side effects. For example, if the evaluation of any expression results in a division by zero error, an error occurs.

Tuesday, June 15, 2010

Amazon Kindle for iPad - Accessibility fail

I'm probably the only iPad owner who didn't know iBooks isn't pre-installed. It showed up when I visited the App Store from the iPad.

In the meantime I tried Amazon Kindle for iPad. It didn't look bad at first, but then I tried VoiceOver. It didn't work at first - then it crashed hard. I had to reset the iPad.

Since I bought the iPad for my visually impaired mother, this was not good.

That's a shame, because I would have liked to have bought books for her on Amazon then put them into a shared Kindle account.

Update: This is weird. Ever since the Kindle debacle, if I try to use VoiceOver the screen goes black. Turns out I'd activated the top secret "screen curtain" feature (limited documentation). A 3 finger triple tap turns it on and blanks the screen. I think this only happens if accessibility is turned on. If VoiceOver is off then three finger tap zooms the screen (not so useful actually, just enlarges pixels). For my mother the "Screen Curtain" will be a bug, not a feature!

Monday, June 07, 2010

iPad for low vision elderly

My 80 yo mother's macular degeneration is limiting her ability to read printed books. I took her to an Apple store this past weekend to see how she'd do with an iPad.

It took us a while to figure out how to configure it. The default accessibility settings assume no vision, so each letter is spoken before it can be selected and entered. Accessibility mode also changes gesture behavior to a less natural mode with a steeper learning curve.

We got the best results with the following setup:
  • From the accessibility menu, configure the screen "home button" to enable VoiceOver on 3 consecutive pushes. (Her arthritis and neuropathy made this a bit tricky, but counting "1, 2, 3" as she pressed did the trick. Once she had the rhythm she could do it reliably.) This lets us turn it on and off as needed, and stay with the standard gestures much of the time.
  • Enable three finger tap to zoom -- and three fingers to move the zoom image. This just magnifies pixels so it's of limited use but it can come in handy. It's normally not compatible with VoiceOver, but if you keep VoiceOver off normally, and enable it just when needed, this can work. From Safari you can get much nicer results from finger zooming web pages
  • Disable the keyboard Voice assist.
  • Slow the VoiceOver rate way down
In iBooks we set the book size to the largest available font. My mother was able to read the sample texts. She could also triple-tap enable VoiceOver, then double tap on the page to have VoiceOver (monotonously but clearly) read the page text.

She had less success with the Safari and Mail.app, but we didn't spend enough time practicing them. Because of the limited zooming of Mail.app and the finger zoom in Safari I wonder if she’ll do better using Gmail.

The iBook experiment was encouraging. She's a sucker for Apple look and feel so she was quite fond of the iPad.

I'm not sure it makes sense to buy her one. For one thing I'm not sure how I can get content on her iPad from my home. If Apple does a bit more work, next year's iPad would be a much better option (though in her age and health, a year is a very long time). If I do go ahead I'll configure it at my home then transfer the paired iTunes Library to her Mac Mini.

See also:
Update 6/11/2010: I did buy her one. Some quick notes from today:
  • Darn. I forgot my AMEX card with its 1 year warrantee extension.
  • There are no ear buds in the box.
  • The charger cable is hard to insert initially. I expect it will be easier with practice. I’ll modify the standard connector (tape, etc) so it’s easier for her to grip and insert.
I’ll write a post later (see update) on how I configure, which apps I use, book buying, how I manage iTunes prep here and then transfer to her, etc. (For one thing, I’ll setup a user account on a laptop for her iPad’s iTunes sync during initial configuration.)


Update 6/14/10: The Kindle is a dismal failure.

Update 6/17/10: Accessibility gestures are documented in the secret User Guide.

Update 8/18/10Grandma's iPad - A user guide and review

Google search result rendering scrambled in Safari

This is what Safari 4 is showing me when I search Google (click for larger image):

A non-moveable "sponsored links" drop down ad is obscuring the left side of the screen and the text below the search button is jumbled.

This is in plain old Safari 4.

WTF?!

Bing works perfectly.

Update: It's broken in Safari 5 too on this machine_account, but it's fine on other machines and other user accounts on this machine. Emptying the cache didn't help. So I reset Safari - restoring default font sizes, clearing cookies, etc. That worked:

I'll change my fonts to larger sizes and see if the bug returns.

Parental controls: Apple and Google joint fail

After an epic struggle, I've given up on Apple's parental controls. They never worked very well, but Google's change to https seems to have broken them completely. I can't enable Google Calendar or Gmail access without also enabling image search. I'm not even sure I can allow allow Google access while blocking YouTube (the rules seem to be changing quickly).

It's a bleedin' mess.

I'm currently evaluating Net Nanny and Safe Eyes, but really I don't want either of them. I need a net appliance I can configure for our entire network. Those devices, however, costs thousands. Or I need to give up on Google.

I'm seriously considering the latter. If MobileMe were to offer Google-class calendaring I could use Bing for family search. I think OS X Parental Controls may still work with Microsoft's offerings.

I have to imagine Windows 7 parental controls are far better than Apple's, otherwise vast numbers of parents must be in full denial ...

Update 6/9/10: xkcd - Now I get it. So this is how things work for those that don't realize quite how bad things are ...

Update 6/14/10: I might be having some limited success with the combination of ...
  1. OS X Parental Controls: whitelist only, with the https://74.125.45.100 trick and our Google Apps family domain.
  2. Google's lock safe search set to the most severe filtering. It's not obvious, but I think you can log in with a parent's personal iGoogle account, lock safe search, then log out. You must, however, enable always receive cookies which is probably a serious security risk. Clearing cookies will clear this, but Parental Controls makes that harder to do.
Update 6/17/11: A comment suggests iBoss Home, a combination of wireless router and a subscription service.

Friday, May 28, 2010

Buzz - getting closer, still not there

Last February Buzz was ailing. Google's been trying to fix it ever since.

I gave it another try today, and there have been real improvements. You can almost achieve, with significant pain, the equivalent of separating Buzz posts from your public google profile. (Google has not implemented the obvious fix -- an option to exclude all Buzz activity from the public profile.)

The main fix so far is that each of the routes to a Buzz post can be configured so the default post is restricted to a set of contacts with associated email addresses that belong to one or more Gmail (Google) Contact Groups.

This includes Buzz posts from Gmail's Buzz UI, from the iPhone Buzz web app, and from each of the "Connected Sites"you can define in Gmail Settings (Buzz).

Configuring these Buzz posts routes, however, is complex and tedious. Each has its own independent settings. So you have to enter the same sets of Groups in Gmail as in iPhone as in Connected Sites. For Connected Sites you must first click "Add", then click "Edit" then apply the settings.

Of course if you later create a new Contacts Group for limited (Private) Buzz sharing, you'll need to revisit all previous settings.

Yech.

Google still needs to:
  1. Have a single Buzz configuration that's shared among all clients.
  2. Allow users to separate their user profile from their Buzz stream.
  3. Ask the guy they hired away from Palm to fix Google Contacts. Puh-lease.
There's certainly progress, but we're still a long way from where we need to be.

Thursday, May 27, 2010

Windows Live Writer - beware the Trojan Horse updater

I received a notice to update my beloved Windows Live Writer* yesterday. I unthinkingly downloaded the installer.

Fool.

It was a Trojan Horse. No, not a "Trojan" as in a carrier for anonymous malware, "Trojan Horse" in the historic sense of a gift containing unwanted vermin.

The installer has plagued my system with a suite of Windows Live products that I don't want and that are almost certain to reduce system stability. Now I have to tediously uninstall:
  • Live Call
  • Live Messenger
  • Photo Gallery
  • Live Family Safety
  • Mail
  • various Outlook add-ins
  • heaven knows what else
Now you know. Don't make my mistake.

*The only good, new, Microsoft product in five years. An acquisition of course. Microsoft has since abandoned it; I think the original (Minnesota?) team is gone. Microsoft is doomed to immense wealth and mediocrity.