1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Search Combo Box

Discussion in 'Business Applications' started by rekeene, Feb 12, 2015.

Thread Status:
Not open for further replies.
Advertisement
  1. rekeene

    rekeene Thread Starter

    Joined:
    Dec 2, 2014
    Messages:
    49
    Hi All,

    I have a search combo box. Is there a way to clear box after search record is found or for the info in the search box to clear once I click in the box to search for another record? I've been manually deleting info in the search box/or highlight and typeover. Thanks.
     
  2. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,608
    First Name:
    Hans
    Hi, In what application? What type of code, VBA? Access? Excel, you name it, we've got enough choice.
    Don't forget to mention version which you are using.
     
  3. rekeene

    rekeene Thread Starter

    Joined:
    Dec 2, 2014
    Messages:
    49
    Oops:eek: I'm using Access 2010. The combo box was created using combo wizard; it's a macro. Thanks.
     
  4. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,608
    First Name:
    Hans
    Hi, this happens ao often :).
    When the macro is run you can add a line of code me.txtbox.value = vbnullstring where txtbox is the name of the search field in your form.
    You could add consditios, if search is suceefull then .... else ..... end if

    I do not have insight on the code you've used but this would be the direction to take, at least, that's the way I would do it.
    VBA is VBA but I am no Access expert, my thing is Excel
     
  5. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    The problem is that the Combo uses a Macro, which is hared to change than VBA.
    It may have a "reset" or set to null option in the Macro list of commands.
     
  6. TerryNet

    TerryNet Moderator

    Joined:
    Mar 23, 2005
    Messages:
    79,614
    First Name:
    Terry
    Reopened per request.
     
  7. rekeene

    rekeene Thread Starter

    Joined:
    Dec 2, 2014
    Messages:
    49
    Thanks.
     
  8. rekeene

    rekeene Thread Starter

    Joined:
    Dec 2, 2014
    Messages:
    49
    Hi,

    I've attached my code.

     

    Attached Files:

  9. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Yes as I said that is actually a Macro and not VBA code.
    You could convert it to VBA code and then add a line of code to it, or you could try adding a line to the macro, this might do it
    In Action select
    SetProperty
    In the Arguments use
    combo1006, Enabled, ""
    You can select those arguments at the bottom of the macro

    PS, sorry that does not work.
    You do not appear to be able to set the field value in a Macro, which means converting the Macro to an Event Procedure with VBA code.
     
  10. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    OK, replace the Macro by clicking on the "Embedded Macro" and select "Event Procedure" instead.
    Click on the 3 small dots to open the Event Procedure at the right place and paste in the following
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[CaseID] = " & Me![Combo1006]
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    rs.close
    Me.combo1006 =""
     
  11. rekeene

    rekeene Thread Starter

    Joined:
    Dec 2, 2014
    Messages:
    49
    Hi,

    I tried the the code and got an error, which I've attached. Thanks.


     

    Attached Files:

  12. rekeene

    rekeene Thread Starter

    Joined:
    Dec 2, 2014
    Messages:
    49
    Nevermind...Once again, I realized I needed to change the names of controls...Thanks a bunch!!(y)

     
  13. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    What is the combo box name?
     
  14. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Does it work?
     
  15. rekeene

    rekeene Thread Starter

    Joined:
    Dec 2, 2014
    Messages:
    49
    I have two databases, and the lookup fields have different names. The code you provided was for one of the tables, which I hadn't realized that names you provided, combo1006 and CaseID, were for one of the dbs. Once I figured that out and applied the code to the correct db, it worked. :)

    Thanks.
     
  16. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1142929

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice