Search Button

txdon32

Registered User.
Local time
Today, 09:34
Joined
Sep 25, 2003
Messages
19
I created a Find Record Button on a form using the wizard. I would like to change the vb code so that the button searches for the same type of record each time.

For example - I want to search in the "Primary Contact" field every time I push the button, without having to place the cursor in that field. I have no clue how to write vb code from scratch, but any suggestions on how to modify the event procedure generated by the wizard would be great!


As always, all help is greatly appreciated!

txdon32 :cool:
 
Try this...
Code:
Sub Find_Record_Button_Click()
On Error GoTo Err_Find_Record_Button_Click
        
    Me.[TextBox_PrimaryContact].SetFocus
    DoCmd.RunCommand acCmdFind
    
Exit_Find_Record_Button_Click:
    Exit Sub
    
Err_Find_Record_Button_Click:
    MsgBox Err.Number & " " & Err.Description
    Resume Exit_Find_Record_Button_Click
    
End Sub
 
Code Problem

Error message: 2465 Microsoft Acess can't find the field 'l' referred to in you expression

Here's the code.....what's wrong with it?

Private Sub Contact_main__Click()
On Error GoTo Err_Contact_Main_Click


Me.[TextBox_Primary Contact].SetFocus
DoCmd.RunCommand acCmdFind

Exit_Contact_Main_Click:
Exit Sub

Err_Contact_Main_Click:
MsgBox Err.Number & " " & Err.Description
Resume Exit_Contact_Main_Click
End Sub
 
txdon32 said:
Me.[TextBox_Primary Contact].SetFocus
DoCmd.RunCommand acCmdFind
I seriously doubt that your text box that is linked to the Primary Contact field in your record source is really name "TextBox_Primary Contact" as my sample displays. Change the "TextBox_Primary Contact" to the name of your text box for that field.

HTH
 
Thanks!!!

It works perfectly now.....thanks a million! :D
 

Users who are viewing this thread

Back
Top Bottom