Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding a specific record on a subform

    Hi!
    I am in the process of creating a database application for my own use in Access 97. I am very new at all of this and the little that I know is self-taught, so please excuse my ignorance.
    Anyway, to get on with it.
    I have created a form (a telephone list), which consists of a "Search" text box and a sub-form. The sub-form displays names and telephone numbers of all my contacts in "continuous forms" view, with a control button to access full details of my contacts if necessary.
    I would like to be able to search for a specific record by entering the name of the contact in the text box and pressing the tab key. When found, I would like the focus to move to the related record on the sub-form, perhaps highlighting the record in a different colour.
    Any help would be greatly appreciated.
    Cheers!

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding a specific record on a subform

    This idea may not be exactly what you're looking for, but I ran across this code in an issue of PC Magazine once. It allowed me to create a "Search as you type" lookup. I've used this on quite a few applications and I LOVE it.
    This feature does require quite a bit of code work, especially when using different data types (number vs. text). However, the article (link below) explains it all step-by-step.
    I hope this helps: Incremental Search-as-you-type Input
    [img]/w3timages/icons/thinks.gif[/img]
    -MarkJ-

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Finding a specific record on a subform

    This is a fairly straight forward process in Access 97. You're going to use the AfterUpdate event of the ComboBox control to call a routine something like this:

    Private Sub cboCompany_AfterUpdate()
    Dim rst As DAO.Recordset
    Set rst = Me.RecordsetClone
    With rst
    If Not .EOF Then
    .FindFirst "[CustomerID]='" & [cboCompany] & "'"
    If Not .NoMatch Then
    Me.Bookmark = .Bookmark
    End If
    End If
    End With
    Set rst = Nothing
    Me!CustomerID.SetFocus
    End Sub

    In this case, since CustomerID is a string (I used Northwind.mdb for this example), You have to add the single quotes around the combobox value in order to match the data type.
    Charlotte

  4. #4
    2 Star Lounger
    Join Date
    Dec 2000
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding a specific record on a subform

    Along with Charlotte's code you may find this helpful.

    The Access Web

    The Access Web is probably one of the best 3rd party Access sites on the WWW.

    FWIW

  5. #5
    New Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding a specific record on a subform

    Thanks for the input. I like the "Search As You Type" idea. Not quite what I had in mind, but close. I will work on it and let you know how I go.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •