Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
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 October 25th, 2003, 08:39 PM
Registered User
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Double search using an input text box


My problem is as follows:

I Have for example this data

ID LastName FirstName Adrress Invoice ETC.
1 McGwire Mac blablabla1 1235
2 McGwire Mary blablabla2 1257
3 McGwire Don blablabla3 1458
4 Adams Homer blablabla4 1489
5 Simpson Elvis blablabla5 1111

The Data is not indexed by ID, but I index it by LastName to make the search easy. I have created a form where the user inputs the last name to search for and the fields above are filled in when it finds the closest Match below the search box. Now I want to be able to search by LastName and then by FirstName qnd get the correct record, but because itùs indexed by LastName, I do not get it correct.

How can I solve this problem



Old October 25th, 2003, 09:32 PM
sal sal is offline
Friend of Wrox
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts

What exactly do you mean by indexed?
The way you set-up an index should not have much bearing on your search, except for the fact htat if the field is not indexed, the search will take longer.
What are you using to create the search? a query?
If you create a sub-form within the main form, showing the users the results of their seqrch by last name, they will be able to view all of their people with that particulat last name, then they can use that form to re-sort by first name and get their result that way.

You could also show them how to do a filter by form.

Hope this helps. Let me know the things that I ask avobe to be able to help you more.


Old October 25th, 2003, 10:29 PM
Registered User
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Sal and thanks for the quick reply.

I am using a pointer, that points to my data base. The code is here:

Private Sub Form_Load()

Set DB = CurrentDb()
Set MyRS = DB.OpenRecordset("tblDecClients", dbOpenTable)
MyRS.Index = "PrimaryKey"

End Sub

Private Sub txtInputSearch_Change()

  Dim strSeek As Variant
  Dim PosinMyRS As Variant

  MyRS.Index = "LASTNAME"

  strSeek = Me![txtInputSearch].Text

    With MyRS
        PosinMyRS = MyRS.Bookmark

        .Seek ">=", strSeek
        If .NoMatch = True Then

        MyRS.Bookmark = PosinMyRS

        Exit Sub

        End If


    End With

End Sub

As you can see, on the form load I force the indexing on the primarykey, but when I go to the txtInputSearch_Change(), I have to index it on the last name to search for the first approximation. In other words if I start inputing Jo, the results will imediatly jump to the closest match, for example Johnson and fill out the other fields with the corresponding data. My problem is, I want to make this routine pick two inputs simultaneously, but when I do this, it is impossible to find the correct one, because the first name is not indexed and he will never find it.

I hope I expressed myself in an understandable way.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing string to a text box in search engine rylemer Classic ASP Basics 0 October 26th, 2005 03:23 PM
Passing string to a text box in search engine rylemer ASP.NET 1.0 and 1.1 Professional 2 October 25th, 2005 06:11 PM
Creating an Input Mask in a text box in VB.NET ysu_computer_lab VS.NET 2002/2003 1 November 5th, 2003 02:40 PM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM

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