473,385 Members | 1,661 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,385 software developers and data experts.

Command button to open Find dialog

How can I program a command button on a form to bring up the standard "Find
and Replace" dialog on click?

Separate but related: how do you run menu commands (e.g. "Edit" "Find") from
VB?

Thanks in advance!

Alex

Mar 3 '06 #1
4 17288
Alex Chun wrote:
How can I program a command button on a form to bring up the standard "Find
and Replace" dialog on click?

Separate but related: how do you run menu commands (e.g. "Edit" "Find") from
VB?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Answer to both questions: use the RunCommand method of the DoCmd
object. E.g.:

DoCmd.RunCommand acCmdFind

The cursor has to be in the control you want to search.

See the VBA Help article on RunCommand for a list of other "menu"
commands available thru RunCommand.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRAiqV4echKqOuFEgEQJzwACfSo0pZmYX2dfYEgGsfUC1a1 6weXUAn2Z0
vVgzUoZM/4I8VAa0GAg+eYY/
=wa69
-----END PGP SIGNATURE-----
Mar 3 '06 #2
This works, except that the command button -- which is unsearchable -- now
has the focus. Is there an easy way to program the button to search the
field that the cursor was in?

Thanks again.

Alex
"MGFoster" <me@privacy.com> wrote in message
news:9T***************@newsread1.news.pas.earthlin k.net...
Alex Chun wrote:
How can I program a command button on a form to bring up the standard
"Find and Replace" dialog on click?

Separate but related: how do you run menu commands (e.g. "Edit" "Find")
from VB?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Answer to both questions: use the RunCommand method of the DoCmd
object. E.g.:

DoCmd.RunCommand acCmdFind

The cursor has to be in the control you want to search.

See the VBA Help article on RunCommand for a list of other "menu"
commands available thru RunCommand.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRAiqV4echKqOuFEgEQJzwACfSo0pZmYX2dfYEgGsfUC1a1 6weXUAn2Z0
vVgzUoZM/4I8VAa0GAg+eYY/
=wa69
-----END PGP SIGNATURE-----

Mar 3 '06 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Assuming the user had put the cursor in the control they wanted to
search, in the Command Button OnClick event put this:

dim ctl as control

set ctl = screen.previouscontrol
ctl.setfocus

Or if you know the control you want the search to be on just indicate
that control:

Me!SearchTextBox.SetFocus
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRAkBFoechKqOuFEgEQJBgwCgiiDl8qedn4WSsnYdl3i9Wj YfgjYAnA5o
Cg3iC0IvY2MT7EnRoY9wYNxV
=GtQz
-----END PGP SIGNATURE-----

Alex Chun wrote:
This works, except that the command button -- which is unsearchable -- now
has the focus. Is there an easy way to program the button to search the
field that the cursor was in?

Thanks again.

Alex
"MGFoster" <me@privacy.com> wrote in message
news:9T***************@newsread1.news.pas.earthlin k.net...
Alex Chun wrote:
How can I program a command button on a form to bring up the standard
"Find and Replace" dialog on click?

Separate but related: how do you run menu commands (e.g. "Edit" "Find")
from VB?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Answer to both questions: use the RunCommand method of the DoCmd
object. E.g.:

DoCmd.RunCommand acCmdFind

The cursor has to be in the control you want to search.

See the VBA Help article on RunCommand for a list of other "menu"
commands available thru RunCommand.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRAiqV4echKqOuFEgEQJzwACfSo0pZmYX2dfYEgGsfUC1a1 6weXUAn2Z0
vVgzUoZM/4I8VAa0GAg+eYY/
=wa69
-----END PGP SIGNATURE-----


Mar 4 '06 #4
put the command button in the form's Header or Footer section, and run
MGFoster's original code from it, as

DoCmd.RunCommand acCmdFind

just put your cursor in the control you want to search before clicking the
button. because the button is not in the Detail section, Access still reads
the "focus" as being on the control, not the command button.

hth
"Alex Chun" <ac***@nospam.u.washington.edu> wrote in message
news:du**********@gnus01.u.washington.edu...
This works, except that the command button -- which is unsearchable -- now
has the focus. Is there an easy way to program the button to search the
field that the cursor was in?

Thanks again.

Alex
"MGFoster" <me@privacy.com> wrote in message
news:9T***************@newsread1.news.pas.earthlin k.net...
Alex Chun wrote:
How can I program a command button on a form to bring up the standard
"Find and Replace" dialog on click?

Separate but related: how do you run menu commands (e.g. "Edit" "Find")
from VB?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Answer to both questions: use the RunCommand method of the DoCmd
object. E.g.:

DoCmd.RunCommand acCmdFind

The cursor has to be in the control you want to search.

See the VBA Help article on RunCommand for a list of other "menu"
commands available thru RunCommand.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRAiqV4echKqOuFEgEQJzwACfSo0pZmYX2dfYEgGsfUC1a1 6weXUAn2Z0
vVgzUoZM/4I8VAa0GAg+eYY/
=wa69
-----END PGP SIGNATURE-----


Mar 4 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Melissa | last post by:
What is the code to delete a command button from a form? Can the code be run from the click event of the button to be deleted? Thanks! Melissa
0
by: Dune | last post by:
Hi there, I have an aspx page that allows users to enter several parameters using drop downs and text boxes. The users then press a button that produces an extract based on the parameters they...
0
by: Me | last post by:
I have an application that has a text box. At the end on the text box is the standard elypsis (command button) for launching the Open File Dialog box. I want the user to select a certain executable...
2
by: Mattbooty | last post by:
Hello, Not sure if anyone else has seen this bug, but I have a form where the entire form is covered with a picturebox. The picturebox has a mouseup event. I also have an open file dialog for...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
4
by: teric2 | last post by:
Hello Everyone! I am trying to use the following code in an on click event procedure from a command button on a custom form set as a dialog box. The dialog box is opened from another form. The...
6
by: John | last post by:
In a form how I can I trap for the action that a user opens the built in 'find dialog'? I would like to trap for it and before the dialog shows up, I would like to execute some code, and after that...
2
by: tejavenkat | last post by:
Hi, I have one scenario i.e Download as csv is there it is a command button when we click on this the save dialog box should be open,Am using javascript how can we do this by using by javascrpt...
1
by: dougmeece | last post by:
Good Morning Experts, I was trying to find a way to automatically open a report in MS Word when I click on a command button. I was not able to find a way to do that. I was able to open the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.