Command Button Help

claddagh

Registered User.
Local time
Today, 20:43
Joined
Jun 15, 2005
Messages
63
Hiya guys,

I have much help from this forum during my latest project, and all help has made me progress at a nice pace....So thanks guys.


The latest problems I have is to do with command buttons.
Really simple i`m sure, but could not find the answer in the search.

I have added a command button to search a refernec number field.
By Default, the search is set to "MATCH Whole Field"
Can I change this to default to "Match Any Part of Field" ???
I have looked in the code section, and cant see where this could be done... But i`m sure its just me not understanding what I`m looking at.


Thanks in advance for any help.

Max
 
In the database menu option select > Tools / Options / Edit/Find, select General Search instead of Fast Search. You may have to close and restart Access for it to take effect.

You can also control the Default Find/Replace Behavior option with VBA.
Code:
    Application.SetOption ("Default Find/Replace Behavior"), 0 'Fast Search
Code:
    Application.SetOption ("Default Find/Replace Behavior"), 1 'General Search
Code:
    Application.SetOption ("Default Find/Replace Behavior"), 2 'Start of field search
And you do not have to restart Access 2003 for it take effect.
 
???

Thanks for the help, I have solved the problem using your first option, which will do temp for now, however, this effects ALL other databases that I have.


I`m a total newbie to the code side of things though.
I would like to make this change using the VB code, so the change only relates to this application database

Where exactly would i define this VB code in the event procedure section.

This is the code part from what I can see that this command button auto creates.

Private Sub Search_Click()
On Error GoTo Err_Search_Click


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

Exit_Search_Click:
Exit Sub

Err_Search_Click:
MsgBox Err.Description
Resume Exit_Search_Click

End Sub

Thanks for the quick responce.

Max
 
I believe that the code version will affect all of your db's since it an Access preference that you are changing.

You can place the code anywhere you want but it only needs to be run once to make the change but the change might not take affect until the next time Access [your db] is opened.
 
VB Code

Thanks, I`ll give that a try,

So by the sounds of it, I can just put the code in its on "module" so to speak.
Not sure of the terminology so please excuse if its said wrong.

The other question I have, is there any way to bind the search button to a particualr field ?

i.e. The search buttong is next to a Reference Number Feild.
At the min, it will search on any field, depending where the cursor is....
Can this be bound to only search the "ref_number" field ????

Thanks in advance..

Max
 
claddagh said:
The other question I have, is there any way to bind the search button to a particualr field ?

i.e. The search buttong is next to a Reference Number Feild.
At the min, it will search on any field, depending where the cursor is....
Can this be bound to only search the "ref_number" field ????

The line
Screen.PreviousControl.SetFocus
makes the "previous" control (the one that had the focus before you clicked on the search command button) the "current field".
You could change this line to
me.YourReferenceNumberFieldName.setfocus

then use
DoCmd.FindRecord
to find the one you want. Look at the parameters it takes, one of them is the setting for search only current field. Set this to True. Make the desired search field the "current" field by setting the focus, as above.

Regards

John.
 
Thanks John

John,

Made the changes that you suggested, at that has worked a treat.

Thanks for the quick responce, this has sorted it out now.
Also applied this to other search buttons in other databases I have, and now the users are happy that they have one less thing to click on ( Lazy Gits ) lol

Thanks once again.


Max
 

Users who are viewing this thread

Back
Top Bottom