473,433 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,433 software developers and data experts.

code for Find and Replace to default "a part of field"

Shakss2
19
I have a form, where I can activate the search and replace dialogbox when
pressing a button.

My problem is that the dialogbox opens with the default that it should
search for full match only, and I want it to open with default "a part of
field".

I did change it to default "A part of the field"?
by going to Tools -> Options menu to open the "Options" dialog window. Select the "Edit/Find" tab. Select the "General Search" option button.

But when I give this to any 1 else to test or for users it again defaults to "Whole field". I cant ask the users to change it at there end.

Can any 1 pls help me with some code which can do this for me.
Where it defaults to "a part of field" for all users who will use this application.

Thanks a ton in advance.

Shaq
Jan 11 '08 #1
10 10759
puppydogbuddy
1,923 Expert 1GB
see this link for answers for this question in another thread:
http://www.thescripts.com/forum/thread201087.html
Jan 12 '08 #2
ADezii
8,834 Expert 8TB
I have a form, where I can activate the search and replace dialogbox when
pressing a button.

My problem is that the dialogbox opens with the default that it should
search for full match only, and I want it to open with default "a part of
field".

I did change it to default "A part of the field"?
by going to Tools -> Options menu to open the "Options" dialog window. Select the "Edit/Find" tab. Select the "General Search" option button.

But when I give this to any 1 else to test or for users it again defaults to "Whole field". I cant ask the users to change it at there end.

Can any 1 pls help me with some code which can do this for me.
Where it defaults to "a part of field" for all users who will use this application.

Thanks a ton in advance.

Shaq
Expand|Select|Wrap|Line Numbers
  1. 'Set to General Search - Part of Field
  2. Application.SetOption "Default Find/Replace Behavior", 1
  3.  
  4.   'do whatever you like in here, but Reset Option at some point
  5.  
  6. 'Reset to Fast Search - Whole Field
  7. Application.SetOption "Default Find/Replace Behavior", 0
Jan 13 '08 #3
missinglinq
3,532 Expert 2GB
I tried using this kind of code to change one of Access' default behaviors (don't remember which one, off hand) and ran into the same problem, I think, that you'll have here; changes to the Default behavior of Find/Replace don't take effect until Access is closed and then reopened. While you can use this to change the default, it won't take effect until the next time Access is opened, and you can't really use the code to reset the behavior. Whichever setting is executed last in the original session is the one that will appear in the next session.

I understand the OP's not wanting to change the Default behavior on users machines, but I don't really see a way around that. I used to have a hack using SendKeys to do this, but it was so buggy (as SendKeys tends to be) I stopped using it. It's probably better letting the users know that they need to change this setting than to merely change it with code, but in reality, most probably don't even know it exists!

The other thing is that even if the code worked as desired, you'd only be guessing at what the user originally had the default set to. It could have already been set to "find any part" and you'd be changing it, which isn't desirable. The way around this, for changing defaults that do take effect without closing/opening Access, is to use the GetOption property, assign it to a global variable (of Integer Datatype) and use it to reset the default.

Behavior Entering Field is one such default that takes effect immediately:

Expand|Select|Wrap|Line Numbers
  1. 'Define global variable
  2. Public intEntryBehavior As Integer
  3.  
  4. 'Get original setting
  5. intEntryBehavior = Application.GetOption("Behavior Entering Field")
  6.  
  7. 'Set option you want
  8. Application.SetOption "Behavior Entering Field", 1
  9.  
  10. 'Reset to original setting
  11. Application.SetOption "Behavior Entering Field", intEntryBehavior
  12.  
Linq ;0)>
Jan 13 '08 #4
ADezii
8,834 Expert 8TB
I tried using this kind of code to change one of Access' default behaviors (don't remember which one, off hand) and ran into the same problem, I think, that you'll have here; changes to the Default behavior of Find/Replace don't take effect until Access is closed and then reopened. While you can use this to change the default, it won't take effect until the next time Access is opened, and you can't really use the code to reset the behavior. Whichever setting is executed last in the original session is the one that will appear in the next session.

I understand the OP's not wanting to change the Default behavior on users machines, but I don't really see a way around that. I used to have a hack using SendKeys to do this, but it was so buggy (as SendKeys tends to be) I stopped using it. It's probably better letting the users know that they need to change this setting than to merely change it with code, but in reality, most probably don't even know it exists!

The other thing is that even if the code worked as desired, you'd only be guessing at what the user originally had the default set to. It could have already been set to "find any part" and you'd be changing it, which isn't desirable. The way around this, for changing defaults that do take effect without closing/opening Access, is to use the GetOption property, assign it to a global variable (of Integer Datatype) and use it to reset the default.

Behavior Entering Field is one such default that takes effect immediately:

Expand|Select|Wrap|Line Numbers
  1. 'Define global variable
  2. Public intEntryBehavior As Integer
  3.  
  4. 'Get original setting
  5. intEntryBehavior = Application.GetOption("Behavior Entering Field")
  6.  
  7. 'Set option you want
  8. Application.SetOption "Behavior Entering Field", 1
  9.  
  10. 'Reset to original setting
  11. Application.SetOption "Behavior Entering Field", intEntryBehavior
  12.  
Linq ;0)>
I used to have a hack using SendKeys to do this, but it was so buggy (as SendKeys tends to be) I stopped using it.
These Key Sequences seem to work fairly well:
Expand|Select|Wrap|Line Numbers
  1. Screen.PreviousControl.SetFocus
  2.   SendKeys "{TAB 2}": SendKeys "{UP 2}"
  3.   SendKeys "+{TAB 2}"
  4. DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Jan 13 '08 #5
missinglinq
3,532 Expert 2GB
What version of Access are you running? Your code doesn't work for me in ACC2003. But like I said, I had other SendKeys code that worked sometimes and didn't work at other times. There's nothing else that has to be set for SendKeys to work, is there?

Linq ;0)>
Jan 13 '08 #6
ADezii
8,834 Expert 8TB
What version of Access are you running? Your code doesn't work for me in ACC2003. But like I said, I had other SendKeys code that worked sometimes and didn't work at other times. There's nothing else that has to be set for SendKeys to work, is there?

Linq ;0)>
Ironically enough, it was tested in Access 2003.
Jan 13 '08 #7
missinglinq
3,532 Expert 2GB
As John Walton was wont to say, "Life's a mystery!"

Linq ;0)>
Jan 13 '08 #8
Shakss2
19
Thanks a ton to ADezii and missinglinq....

It made my life easy...
it works as said by you guys.

Thanks and regards,
Shaq
Jan 16 '08 #9
ADezii
8,834 Expert 8TB
As John Walton was wont to say, "Life's a mystery!"

Linq ;0)>
Was this the same John Boy Walton of The Waltons (LOL)?
Jan 17 '08 #10
missinglinq
3,532 Expert 2GB
Nope! Was his daddy!

Linq ;0)>
Jan 17 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: AA Arens | last post by:
When I place a record serch utility (vos the button placement wizzrd), I discovered that the Match setting is "Whole Field" by default. How to make "Any Part Of Field" default?
6
by: Marty | last post by:
Hi, I would like to replace "\r\n" by "_" within a specific string. I tried : strMyString.Replace('\r', '_'); strMyString.Replace('\n', '_'); or...
3
by: nan | last post by:
Hi All, I am trying to connect the Database which is installed in AS400 using DB2 Client Version 8 in Windows box. First i created the Catalog, then when i selected the connection type...
3
by: Louis | last post by:
I have a problem using the REPLACE method. Here is a short description: In a.html: I used the following to call the chgtitle function: <a href=" "...
0
by: Jon | last post by:
If anyone can help...Whenevr I go into a form and use the ctrl+F to find something with the binoculars the "Search field as formatted" is checked as default. This seems to slow down the find...
0
by: Rave | last post by:
This is a long shot, but I thought I'd try it. I am currently using excel as an inventory tool. I currently have a hand-held scanner plugged into a laptop for reading barcodes. Using the "Find and...
2
by: John Nagle | last post by:
I'm trying to clean up a bad ASCII string, one read from a web page that is supposedly in the ASCII character set but has some characters above 127. And I get this: File...
2
by: Winks | last post by:
In the 2003 version I was able to change the default "Look In" and "Match" settings for the Find dialog box. I have looked all over 2007 and cannot find where to set the defaults. Can anyone...
6
matthardwick
by: matthardwick | last post by:
Is there a way to make the find box (Ctrl+F) default to match "Any part of field" instead of "Whole field". Thanks in advance. Matt.
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.