Search Combo Box

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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.
 

Keebellah

Hans
Trusted Advisor
Joined
Mar 27, 2008
Messages
6,639
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.
 

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.
 

Keebellah

Hans
Trusted Advisor
Joined
Mar 27, 2008
Messages
6,639
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
 

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.
 

rekeene

Thread Starter
Joined
Dec 2, 2014
Messages
49
Hi,

I've attached my code.

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
 

Attachments

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.
 

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 =""
 

rekeene

Thread Starter
Joined
Dec 2, 2014
Messages
49
Hi,

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


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 =""
 

Attachments

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.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Members online

Top