What’s That Form?
By Andy Lacey
Have you ever been in the following situation: A client or user calls you in to look at an application you wrote for them. Someone clicks on a command button to open another screen, and then use an obscure option (that you can’t even remember programming) that does a pile of stuff and presents new data. The client then turns to you and says: “Could you add the delivery date to this screen?”
The same thing can happen when you inherit an application. Only worse, because this time you were lost when the user opened the first screen, and after that your eyes glazed over, and now you haven’t a hope in hell of remembering the steps which led here.
Either way, finding out which screen it is that requires the change is at best a drain on your time and at worst an embarrassment. If you can get away to the safety of your own desk it’s not too bad. You can do your investigating in private. If, however, the user is looking up expectantly waiting for you, the IT expert, to demonstrate your prowess, then you’re going to have to do some fast talking to avoid having to admit that you don’t have the first idea where to look.
So here’s a simple technique to save your bacon, or at least your blushes. In your Autokeys macro (look it up in Help) add an entry for, Ctrl-Q that has an action of RunCode and a Function Name of ShowScreens(). Then put the following few lines into a module:
Public Function ShowScreens()
Dim frm As Form
Dim strMess As String
' Enumerate Forms collection.
For Each frm In Forms
' Store name of each form.
strMess = frm.Name & vbCrLf & strMess
Next frm
' Display the list of open screens
Call MsgBox("Current open screens are: " & vbCrLf & strMess)
Set frm=Nothing
End Function
I’ve deliberately omitted error handling so that you can see the simplicity of the code. The next time that situation occurs just lean over, hit Ctrl and Q and read off the form names: the last one opened will be at the top of the list. Your menu or initial screen will be at the bottom. You’ll save yourself a lot of time browsing code and, most importantly, you’ll look like you know what you’re doing.
Whether you can add that delivery date to the screen I have absolutely no idea.
Please contact the author at andy@minstersystems.co.uk to ask questions or report errors.
Andy Lacey ©2002
May be distributed as long as the copyright remains.
Andy Lacey
Bio