Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 17th, 2008, 04:17 AM
Authorized User
 
Join Date: Nov 2005
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?

Help!!

Bmulenga
__________________
Bmulenga
 
Old January 17th, 2008, 08:45 AM
Authorized User
 
Join Date: Oct 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

 
Old January 17th, 2008, 11:55 AM
Authorized User
 
Join Date: Oct 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 & "*'"
    Else
        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] = ""

    Me![txtNameFilter].SetFocus







Hope this helps.







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





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