Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 17th, 2008, 04:17 AM
Authorized User
Join Date: Nov 2005
Location: Lusaka, Lusaka, Zambia.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Find or Search Operation

Every time when I have created a Command Button for a Find or search operation and use it to perform a find operation, Access brings the inbuilt dialog where I type the criteria. However, if I use part of a word to search I have to continue clicking find Next till I find the word or name I was looking for. Is there a way where when you type the search criteria, a list of all matching words is displayed and then you click the one you are looking for?


Reply With Quote
  #2 (permalink)  
Old January 17th, 2008, 08:45 AM
Authorized User
Join Date: Oct 2007
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts

If you are creating the Command Bottom in a form you could instead create a filter operation in VBA based off of a combo box. The filtering code will allow you to find the record you are looking for, and by using a combo box based off of the table you are working with you would have the ability to start trying and then chose the word you are looking for.

Reply With Quote
  #3 (permalink)  
Old January 17th, 2008, 11:55 AM
Authorized User
Join Date: Oct 2007
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts

When you filter a form it is very similar to running the find command botton that is built into access. Once you run the filter though only the records that meet the criteria will be displayed in the form. Along with the filer bottom you will also have to create a remove filter botton to remove the filter when you are done with it.

The nice thing about a form filter with a combo box is that you can very quickly find the record you are looking for.

The first thing you need to do is to create a combo box, in the table/query property field for the combo box choose the name field from table A. Depending on how you created your form you might have to include and use the field ID, but I am going to guess that you will not have to include the ID field. Start with just the name field, you will have to determine this depending on your form. Name the combo box something like txtNameFilter.

You will then need to create a filter bottom and put the VBA code on the onClick procedure. Something like.

Assuming the name field in your table is actually called Name

varNameFilter = Me.txtNameFilter

    If varNameFilter <> "" Then
        varNameFilter = "Name like '*" & varNameFilter & "*'"
        varNameFilter = "Nz([Name]) like '*'"
    End If

    [Forms]![Name Of Your Form].Filter = varNameFilter
    [Forms]![Name Of Your Form].FilterOn = True

The last thing you will need to create is a remove filter bottom. This code will also be on the onClick procedure.

DoCmd.RunCommand acCmdRemoveFilterSort
    Me![txtNameFilter] = ""


Hope this helps.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
urgent help needed in ldap search operation vidhyachat J2EE 0 May 12th, 2007 06:29 AM
Open Word Doc from Access - find, find next save donaldmaloney Access VBA 1 May 25th, 2005 11:09 AM
No log operation acko SQL Server 2000 0 April 2nd, 2004 04:10 AM
Create a find and a find and replace in VB.NET snowy0 VB How-To 0 January 26th, 2004 07:03 PM

All times are GMT -4. The time now is 06:58 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.