Link to home
Start Free TrialLog in
Avatar of mlcktmguy
mlcktmguyFlag for United States of America

asked on

Repalcement For Find In Newer Versions Of Access

I developed an application in Access 2003 for a client many years ago.  I used a 'Find/Binocular' button on the form which had this code behind it.

    DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Open in new window


It is the generic 'Find' with the binoculars showing.

Six months ago the client upgrade to Access 2010 with no changes to the MDB and the command button has continued to work.

I recently updated the MDB on a machine running Access 2010.  I didn't make any changes to the form the 'Find' command is on and I left the app as an MDB.

Now the Find/Binocular button doesn't work.

I know that the format of the find is not supported anymore but it worked running in Access 2010 until I made non (Find) related revisions to the app.

Is there a reference I can add to get the find to work?  If not, what command replaces the find command I am using in newer versions of Access?
ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mlcktmguy

ASKER

Thank you, I made the chnange  but I am getting runtime error '2046' The command or action Find isn't available now when I press the button.

Here is the code in my module:
'
    If Me.Dirty Then
      response = MsgBox("You have made changes to this record." & Chr(10) & Chr(13) & "Save these changes?", vbOKCancel)
      If response <> 1 Then
         Me.Undo
         GoTo FindIt99
      End If
'
      Any_Edit_Errors = True
'
      Edit_Record
'
      If Any_Edit_Errors = True Then
          Exit Sub
      End If
'
      AlreadyUpdated = True
'
    End If
'
FindIt99:

    Screen.PreviousControl.SetFocus
    DoCmd.RunCommand acCmdFind
'
End Sub

Open in new window

Then Access is completely locked up.  I can't close the form using my user defined 'Exit' button or the 'X' in the upper right hand corner of the form.
I can't close Access using the 'X' in the upper right hand corner of Access.  I have to use the task manager to cancel Access.
I get no messages but nothing will close.

I also tried building  the button using the wizard, which resulted in this code.
Private Sub btnSysytemFind_Click()
On Error GoTo Err_btnSysytemFind_Click


    Screen.PreviousControl.SetFocus
    DoCmd.RunCommand acCmdFind

Exit_btnSysytemFind_Click:
    Exit Sub

Err_btnSysytemFind_Click:
    MsgBox Err.Description
    Resume Exit_btnSysytemFind_Click
    
End Sub

Open in new window


Since there is an error handler I get the same message ' The command or action Find isn't available now' in a message box but the application doesn't lock up.

Either way the Find isn't working.
This is the correct command.  The issue was being caused because I was opening the form with acDialog specified
Ah. I see.  I wouldn't have guessed that this code was inside a modal/dialog instance of the form.
Strangely that had been the same and worked perfectly for many years.  It was only when I worked on this form in Access 2007 instead of Access 2003 that this problem came up. I even kept the application as an MDB.
I've encountered similar differences in applications run 2007+ versions of Access that worked just fine in 2003.