Clear Form

D

DS

I know there is a command that you can use to clear the fields of a
search form after the search is done but for the life of me I can't
remember it.

I thought it was DoCmd.Refresh that didn't work.
Then I thought it was DoCmd.Clear but that doesn't exsist.
Any help appreciated.
Thanks
DS
 
J

John Vinson

I know there is a command that you can use to clear the fields of a
search form after the search is done but for the life of me I can't
remember it.

I thought it was DoCmd.Refresh that didn't work.
Then I thought it was DoCmd.Clear but that doesn't exsist.
Any help appreciated.
Thanks
DS

Depends on whether you mean an unbound form (as I'm guessing you mean
by a "Search Form"), in which case you can use Me.Undo - or a bound
form, in which case DoCmd.GoToRecord acNewRecord would be preferable.

John W. Vinson[MVP]
 
D

DS

John said:
Depends on whether you mean an unbound form (as I'm guessing you mean
by a "Search Form"), in which case you can use Me.Undo - or a bound
form, in which case DoCmd.GoToRecord acNewRecord would be preferable.

John W. Vinson[MVP]
Its a search form with unbound fields...Me.Undo doesn't work. I tried
it on the closing of the search form, which really doesn't close it just
goes invisible. I also tried it on the on open of the search form from
a command button on the main form.
Thanks
DS
 
J

John Vinson

Its a search form with unbound fields...Me.Undo doesn't work. I tried
it on the closing of the search form, which really doesn't close it just
goes invisible. I also tried it on the on open of the search form from
a command button on the main form.

Hrm. Well, I wouldn't expect either of those to work - you wouldn't
WANT to clear the form in the course of making it invisible, because
the whole point is to have data on the form for the target Report or
Form to use as criteria. The command button on the mainform should
also not include a Me.Undo since that would undo any changes to the
*main* form, not the search form (probably harmless since there are
likely no edits at that point, but useless too).

What happens if you use

Forms!searchform.Undo

in the main form's command button?

You might need to loop through the controls on the search form setting
them to Null, but I would have thought that Undo should work.

John W. Vinson[MVP]
 
Top