Results 1 to 7 of 7
  1. #1
    gafort is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Cleveland, Ohio
    Posts
    22

    Search button on form help

    I have a database at work that I did not write completely. I can put my cursor in any field and hit search and the search/replace message box appears. I'd like to do this on my new database as well but the copied code does not work the same. Methinks I have to create a query? Here is the code from the first working database:

    Private Sub btnFind_Click()
    On Error GoTo Err_btnFind_Click


    Screen.PreviousControl.SetFocus
    DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
    ***I'd like to learn what these items do***


    Exit_btnFind_Click:
    Exit Sub


    Err_btnFind_Click:
    MsgBox Err.Description


    Resume Exit_btnFind_Click

    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    I don't think a query is necessary but I've never used code like this. I build other search mechanisms. Can't you look at the design of form in other db and replicate structure?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    gafort is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Cleveland, Ohio
    Posts
    22
    Quote Originally Posted by June7 View Post
    I don't think a query is necessary but I've never used code like this. I build other search mechanisms. Can't you look at the design of form in other db and replicate structure?
    This is the code I copied from the working database. It brings up the Find and Replace box. That is what I am trying to replicate in the new database.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    But what is different about the forms that makes the code not work? I would have to review db. If you want to provide, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    gafort is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Cleveland, Ohio
    Posts
    22
    This is the working database. I am trying to duplicate the search function like this one. Looks easy but is not working in new database.

    This is the database I am trying to get the search button to work on.
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Need to select [Event Procedure] in the button Click event property. I did that and by debugging I see the event runs but still not seeing the Find dialog opening because code should be:

    DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

    You had:

    DoCmd.FindRecord acFormBar, acEditMenu, 10, , acMenuVer70
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    gafort is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Cleveland, Ohio
    Posts
    22
    I was trying different things and forgot to change back to original before sending to you. Sorry about that. Strange thing is, when I changed it back, it started working. Odd, but I'll take it. Thanks for your help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 07-13-2012, 01:15 AM
  2. Replies: 12
    Last Post: 03-22-2012, 02:48 AM
  3. Search Button in a Form
    By spideynok in forum Forms
    Replies: 14
    Last Post: 03-18-2012, 10:08 PM
  4. Replies: 9
    Last Post: 02-15-2011, 03:05 PM
  5. search button on Form
    By josejuancruz in forum Access
    Replies: 1
    Last Post: 12-23-2010, 07:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums