Search Command Button

danassef

New member
Local time
Today, 00:52
Joined
Dec 28, 2006
Messages
7
I have placed a command button to find a record on my form using the wizard. When I click on the button the "look in" box on the Find Screen that appears always list the the box that previously had the focus. So if I look for a certain ticket number and change a customers order once I click on the command button the last field I entered information into is list in the look in box. How do I change this so when I click on the find a record button it looks in the same field each time instead of switching each time? I have a field for ticket number that I want to do the search whenever the command button is clicked. Below is the code written by the wizard.


Private Sub Find_Ticket_Number_Click()
On Error GoTo Err_Find_Ticket_Number_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Find_Ticket_Number_Click:
Exit Sub

Err_Find_Ticket_Number_Click:
MsgBox Err.Description
Resume Exit_Find_Ticket_Number_Click
 
Cannot be done using "default coding" sorry...

Have a search for "recordsetclone" in the access help
You will find this sample:
Code:
Sub SupplierID_AfterUpdate()
    Dim rst As Recordset
    Dim strSearchName As String

    Set rst = Me.RecordsetClone
    strSearchName = Str(Me!SupplierID)
    rst.FindFirst "SupplierID = " & strSearchName
        If rst.NoMatch Then
            MsgBox "Record not found"
        Else
            Me.Bookmark = rst.Bookmark
        End If
    rst.Close
End Sub
See if you can addapt it to your needs, if not post back with any questions you have

Good Luck
 
Change

Code:
Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

to

Code:
Me.[B]YourTicketNumberField[/B].SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Simply substitute your actual field name for YourTicketNumberField.
 

Users who are viewing this thread

Back
Top Bottom