How to reset a custom search dialog form?

  • Thread starter Thread starter Doug Vernon
  • Start date Start date
D

Doug Vernon

I have created a custom dialog box with several unbound
object frames. The unbound object frames are used to
enter variables used by a query. I would like to make a
command button that will clear the contents (or "reset")
of all of the unbound object frames on the form.

My current method for "resetting" the form is by using a
macro that closes the form, then re-opens it. . . it
works but it is not very smooth looking.

Any ideas would be greatly appreciated.

DV
 
The custom dialog box actually contains "unbound text
boxes" instead of unbound object frames.
DV
 
Doug,

Here is some sample code from a criteria form that I use. Hope it helps. The
error numbers in the error handler take care of trying to set a control to
null when it is a type that doesn't have a value.

Gary Miller

' **************************************
Private Sub cmdReset_Click()
On Error GoTo ResetError
Dim Frm As Form, Ctl As Control

Set Frm = Me
For Each Ctl In Frm
Ctl.Value = Null
Next Ctl

ResetError:
If Err = 2119 Or Err = 438 Or Err = 2448 Then
Resume Next
ElseIf Err > 0 Then
MsgBox Err & ": " & Err.Description
End If
End Sub
*************************************************
 
Back
Top