Clear Query Results

R

ridawg

Hey,

I've created a form connected to an Access database using the connection
wizard. Within this form I've created 3 views: Search, Details, New Record.

The Search view has a button that switches views to the New Record view,
query fields & query button, and a repeating table for the results & within
the results I have a button that I use to switch views to the Details view.

Here's the problem:
When I enter a new record in the New Record view the database is updated no
problem but I then select a button I created called Return to Search - this
button switches the view back to my Search view - this is where the problem
occurs.

The Search view lists my new record - I would like the Search view to be set
back to nothing like when you first open the form. The reason being the next
time I select the New Record button it displays my new record instead of
switching to this view with all the fields blank (essentially ready for
entry).

So I think I need to write some code that when my Return to Search button is
clicked it not only switches to the Serach view but it also clears the
previous results.

Any help is greatly appreciated!
 
S

S.Y.M. Wong-A-Ton

How about adding a rule to your Return to Search button that sets the fields
on the Search view to their initial values? Create a rule on the button,
select "Set a field's value", select the field on the Search view you would
like to reset, and enter "" (an emptry string) for text fields or enter a
formula if desired for other types of fields.

Regards,
S.Y.M. Wong-A-Ton
 
R

ridawg

Thanks for this idea but I already tried that. This will set the query fields
back to their initial values but it doesn't actually clear the results of the
initial query or prevent the my new record being returned in my results
section. I did find a solution that solves this problem. Basically using a
button with it's action set to New Record. After entering a new record and
submitting it, you can then click on the return to search button (with it's
action set to new record) and it will by default switch to the form's default
view and clear the query results fields (what infopath calls datafields).
 

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