Need help searching for records 
Author Message
 Need help searching for records

I have the following code in a button.  I'm trying to speed the
record searching up, does anybody have any suggestions?  I have
everybody complaining about how slow Access is.  I really think
it is my code.  I can do searching by fields so I never got seek
to work right for me.  

Private Sub SearchButton_Click()
'do error handling
On Error GoTo SearchErrorHandler
'Make sure NoMatchFlag is false
NoMatchFlag = False
If FindText.Visible = True Then
    'Set the Variable for the find item.
    FindItem = FindText.Text
    'Check & make sure FindItem is not empty.
    If FindItem = "" Then
        MsgBox "Must Add A Value.", 48, "Search Button"
        Exit Sub
    End If
Else
    FindItem = FindCombo.Text
End If

'Make sure a field has been chosen
If ItemSearchField = "" Then
    ItemSearchField = "Problem"
End If

'Set variable for TextOne so we can come back to
'orginal record if no match.
TextOne = Text1.Text
'assign the field for searching
Text1.DataField = ItemSearchField
CLMotData.Refresh
'Move to the first record.
CLMotData.Recordset.MoveFirst
'Run a loop till we hit the search junk
Do Until Text1.Text = FindItem
    'Advance the record
    CLMotData.Recordset.Update
    CLMotData.Recordset.MoveNext
    'Check & see if we have hit the End Of File.
    CLMotData.Recordset.Update
    If CLMotData.Recordset.EOF = True Then
        'Do a refresh
        CLMotData.Refresh
        'Move to the first Record.
        CLMotData.Recordset.Update
        CLMotData.Recordset.MoveFirst
        'Display a message box.
        If SearchAddNewFlag = False Then
            MsgBox "No match found.  Searching for orginial
record.", 48, "Search Button"
        Else
            'Set the find item to TextOne
            FindItem = TextOne
            'Assign the textbox datafield
            Text1.DataField = "Serial Number"
            'Set the nomatchflag
            NoMatchFlag = True
            'Get out of here.
            Exit Sub
        End If
        'Set the find item to TextOne
        FindItem = TextOne
        'Assign the textbox datafield
        Text1.DataField = "Serial Number"
        'Set the nomatchflag
        NoMatchFlag = True
    End If
Loop

'Reassign text1.datafield to orginal
Text1.DataField = "Serial Number"
'See if there is no match
If NoMatchFlag = True Then
    'Exit sub if no match
    Exit Sub
End If

'Hide all the find stuff.
FindCombo.Visible = False
FindFrame.Visible = False
FindText.Visible = False
SearchButton.Visible = False
FindItemCombo.Visible = False
'Reset flags
NoMatchFlag = False
'exit sub if no error
Exit Sub
'Do the error handling
SearchErrorHandler:
MsgBox "Error = " & Error$, 16, "SearchButton_Click"
Call CLMotData_Error(Err, 0)
If ExitProgram = True Then
    Exit Sub
Else
    Resume Next
End If
End Sub



Wed, 02 Sep 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Need help searching for records

2. NEED ASSISTANCE w/ coding to search specific field in a record

3. Moving From Record to Record - Need Help Please

4. How can I Search for a record in an Access Database that contains my search query

5. Help! Help needed on searching database

6. NEED HELP WITH A SEARCH FUNCTION IN VB, PLEASE HELP

7. word 2002 record macro won't record searching for font atttibutes

8. Help with recordset to search one record.

9. Help on fast database record search

10. Searching a database for a specific record (help)

11. Complicated search form help needed!

12. Need Help - Searching Memo Fields For Strings

 

 
Powered by phpBB® Forum Software