My muddiness when it comes to OpenArgs
I was getting an syntax error message when I clicked on a New button on the Equipment Quick Finder form. The equipment form in the Granite Fleet Manager executes a reasonable amount of code on startup.
I had added that New button to the Quick Finder form when I created it and all was well. Trouble is I added some code in the Equipment form that required the OpenArgs start with "New" when the record did not exist. And now the code was causing me troubles. While I fixed the immediate problem I realized I had a larger issue.
When testing I realized that if I'm updating a piece of equipment then the OpenArgs will legitimately be empty.
So I added the following code in the forms Open Event.
If IsNull(Me.OpenArgs) And Len(Me.Filter) = 0 Then _
MsgBox "OpenArgs is null and Filter is empty."
I also did a Find through all the code looking for OpenForm "Equipment" just to ensure I didn't have any other problems hidden away somewhere else.
The lesson is that if you are depending that OpenArgs have values in it ensure that values are always present. Pop up a message for the programmer to give him (or her) a kick.
This is a follow up to the Watch out for Null OpenArgs blog posting. (And I sincerely hope my clients never chip in to purchase the chair mentioned at Microsoft: We Share Your Pain.)