ACC2: Find Record Wizard Command Button Has Options Disabled

ID: Q126866


The information in this article applies to:


SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

When you choose a Find Record command button that you created with the Command Button Wizard, the Search In option buttons and the Search Fields As Formatted check box are unavailable in the Find dialog box.


CAUSE

When you choose the command button, the command button receives the focus. The Search In option buttons and the Search Fields As Formatted check box are available only when the Find dialog box is invoked from a text box that is based on a field.


RESOLUTION

Add the following line to the code that is generated by the Command Button Wizard so that the focus is returned to the control that had the focus before you chose the command button:


   Screen.PreviousControl.SetFocus 

To add this code, follow these steps:
  1. Open the form containing the command button in Design view.


  2. Use the right mouse button to click the command button that you created with the Command Button Wizard, and then choose Build Event from the menu that appears.


  3. Add the following line as the second line of code in the module:
    
          Screen.PreviousControl.SetFocus 

    After you add the line, the code should be similar to the following sample code:
    
          Sub ButtonX_Click ()
             Screen.PreviousControl.SetFocus
          On Error GoTo Err_ButtonX_Click
    
             DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, 10, , A_MENU_VER20
    
          Exit_ButtonX_Click:
              Exit Sub
    
          Err_ButtonX_Click:
              MsgBox Error$
              Resume Exit_ButtonX_Click
    
          End Sub 


  4. Save the form.



STATUS

Microsoft has confirmed this to be a problem in Microsoft Access version 2.0. This problem no longer occurs in Microsoft Access version 7.0.


Keywords          : kbusage WzProb 
Version           : 2.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: April 9, 1999