Bring up find box only if it was previously up

D

Dan

I have a form that I print envelopes off of. I have it so
that I click the print button and it will print the
envelope and then select the last name and then bring up
the find/replace box so that I can just type the next
name that I need to find and print rather than clicking
on the field that I want to search and then back on the
search box. This is the code that runs when I click the
print button:

Dim stDoc As String

stDoc = "print"
DoCmd.RunMacro stDoc

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

I want it so that it will only run this code if the
find/replace box is open. Now if you click the print
button and the find/replace box is not open it prints the
form and then opens the find/replace box.
 
H

Hugh O'Neill

Dan said:
I have a form that I print envelopes off of. I have it so
that I click the print button and it will print the
envelope and then select the last name and then bring up
the find/replace box so that I can just type the next
name that I need to find and print rather than clicking
on the field that I want to search and then back on the
search box. This is the code that runs when I click the
print button:

Dim stDoc As String

stDoc = "print"
DoCmd.RunMacro stDoc

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

I want it so that it will only run this code if the
find/replace box is open. Now if you click the print
button and the find/replace box is not open it prints the
form and then opens the find/replace box.


The more usual tools for doing this task would be to use a combo box on
your form to find the record, then your 'Print' button would open a
Report that prints the current record. Those would be the correct
tools for that job. The wizards will take you though the steps.

hth

Hugh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top