How to clear a Search Form

C

ChicagoPete

So I have a VERY simple Access 2007 db to store location of products. I have
a ProdID, ProdName, ProdLocation.
Yes, I used a switchboard wizard that has a few buttons - "Enter new
product", another button to "Search". When I click on the "Search" button it
opens frmSearch - the user fills in the ProdName or ProdID, clicks on a
Search button which opens a split form called frmSearchResults (it's data
source is qrySearch).
On frmSearchResults I have a button that goes back to the "Switchboard" and
another button to "Return to Search".
If you click on "Return to Search" - frmSearch opens but still displays the
values from the last search.

It seems to me that the original frmSearch form is still open in the
background when frmSearchResults opens, so how do I clear ALL fields before
frmSearch opens? Is there an OnLoad or OnOpen event I can use here? Or
OnClose of frmSearch?

For the purpose of this simple db, we decided to use wizards and no code so
as this db moves from dept to dept it should be easy to understand/debug -
nothing fancy here!
 
A

Allen Browne

What does the 'go back to Switchboard' button do?

Try adding this at the end of the code:
DoCmd.Close acForm, Me.Name

You could use the search form's Activate event to set all your unbound
search boxes to Null.
 
C

ChicagoPete

Hey Allen,
"Go back to Switchboard" from frmSearchResults was intended to take the
user back to frmSearch to perform a new search. So we would like the form to
be blank again...
 
A

Allen Browne

I'm asking what code is in the event that takes you back to the
*switchboard*.

Try adding the line to the end of that code.
 
C

ChicagoPete

Sorry, my misunderstanding...

I used the button wizard and it created the On Click event with an Embedded
Macro of CLOSE form.

AAAHaaa! So all it is doing is just closing my frmSearchResults form and
since the frmSearch is still open that's why I see my 'old' input.
 
C

ChicagoPete

Sorry - just reread my last post.

On frmSearchResults I have the button "Return to Search" - this is my
problem. When clicked it merely closes the frmSearchResults form and since
frmSearch is still open that's why I see my old entries. My intention is when
the button Return to Search is clicked, frmSearch opens with all blank fields
- ready for a new search.

The button "Return to Switchboard" works fine..

Sorry again for the confusion - is it still Monday?
 
C

ChicagoPete

I reviewed what the 'button wizard' did and I added some addditional
actions/arguments to open and close the forms as needed.

Thanks again for your time and patience.
 

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