Results 1 to 4 of 4
  1. #1
    rmrha21 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Dec 2014
    Posts
    2

    VBA Search code not working

    Hi I am very new to VBA, and I am receiving an error I am not sure how to resolve. I have a form set up so that when I click on a box it opens a form that allows me to search employees. I just switched from Access 2010 to 2013 and when I click on the box the form no longer opens. I have attached the code that I use. The code opens up various boxes to add new team members, search, etc. How do I resolve this error so I can use the search function again?

    [Private Sub btnCSat_Click()
    DoCmd.OpenForm "frm_CSatTeam", acNormal, , , acFormPropertySettings


    End Sub

    Private Sub btnExit_Click()
    'DoCmd.CloseDatabase
    DoCmd.Quit
    End Sub

    Private Sub btnNewMember_Click()
    DoCmd.OpenForm "frm_TeamMember", acNormal, , , acFormAdd
    End Sub

    Private Sub btnRefresh_Click()
    sfmTeamMember.Requery
    End Sub

    Private Sub cmbRegion_AfterUpdate()
    'sfmTeamMember.Form.Filter = "Region = " & Me.cmbRegion
    If sfmTeamMember.Form.Filter = "" Then
    sfmTeamMember.Form.Filter = "Region = '" & Me.cmbRegion & "'"
    Else
    sfmTeamMember.Form.Filter = sfmTeamMember.Form.Filter & " AND Region = '" & Me.cmbRegion & "'"
    End If
    sfmTeamMember.Form.FilterOn = True
    End Sub

    Private Sub btnRecords_Click()
    DoCmd.OpenForm "frm_TeamMember", acNormal, , , acFormEdit
    End Sub

    Private Sub btnSearch_Click()
    DoCmd.OpenForm "frm_Search", acNormal, , , acFormEdit
    End Sub]

    Thank you!
    Attached Files Attached Files

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,608
    What is the error message you are getting, and which bit of code (i.e. which button) is causing it?

  3. #3
    rmrha21 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Dec 2014
    Posts
    2
    Quote Originally Posted by John_G View Post
    What is the error message you are getting, and which bit of code (i.e. which button) is causing it?
    The error is Run-time error '3151':
    ODBC--connection to 'OPS_TMS' failed

    All of the code is giving the same error.

    Thank you!

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,608
    That error suggests the forms you are trying to open are bound to tables in an external database, and the connection to that external database is no longer valid.

    What is the recordsource for those forms?

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

Similar Threads

  1. Search not working in my form
    By scorpion99 in forum Forms
    Replies: 3
    Last Post: 11-06-2014, 01:37 PM
  2. Replies: 2
    Last Post: 06-28-2013, 12:58 PM
  3. Search box not working
    By banker in forum Forms
    Replies: 2
    Last Post: 08-16-2012, 07:59 PM
  4. Combo Box search not working
    By Lowell in forum Forms
    Replies: 1
    Last Post: 06-02-2012, 12:53 AM
  5. Msgbox And Search Code Not Working Properly
    By vampyr07au in forum Forms
    Replies: 1
    Last Post: 05-02-2011, 05:16 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
  •  
Tech Forums: Microsoft Office Forums