June 25 - July 1, 2007
Determining the control that last had focus (Access 97/2000/2002/2003)
There may be times when you want a VBA procedure to work with the control that last received focus. For example, when a user clicks on a command button, you want the button's Click event procedure to perform some action on whatever textbox control was previously selected. Fortunately, Access includes a property for this exact role--appropriately enough, it's named PreviousControl.
The PreviousControl property applies to the Screen object. To demonstrate, open a form that contains several controls in Design view. Add a command button and name it cmdLastFocus. Then, click the Code button to open the VBE. Add the following procedure:
Private Sub cmdLastFocus_Click()
MsgBox Screen.PreviousControl.Name
End Sub
Switch back to Form view and select any of the controls. Then, click the cmdLastFocus button. The message box displays the correct control name regardless of which control had focus before clicking the button.
Drag and drop selections in place (Photoshop 6/7/CS)
To move something from one Photoshop document to another, you can copy and paste the selection. However, this copies the selection to the clipboard, which uses up a lot of RAM. Alternatively, you can drag an image, selection, or layer from one window to another using the Move tool. To center an image, selection, or layer, press the [shift] key as you drag it into the new document.
Create new event handlers to process control events (Visual Basic .NET)
Visual Basic .NET allows you to modify the default event handlers for a control to process any number of events from any control on the form. However, if you prefer, you can leave the default event handlers alone and create your own event handlers to process the events along with, or in lieu of, the original event handler. To illustrate a simple event handler, we added two buttons to a default Windows Application form. We then used the following code to create a new event handler:
Private Sub HandleAllClicks(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click, Button2.Click
MsgBox("You Clicked " & CType(sender, Control).Name)
End Sub
This code creates a HandleAllClicks() event to process the Click() event for each button. It then displays the name of the control you clicked. It does so without affecting the existing Click() event subroutines for the buttons. If you wish, you can also place code in the default Click() events for the buttons and process the event twice. However, you’ll have no control over which event code .NET executes first.
|