How to reset a custom search dialog form?

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
 
D

Doug Vernon

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

Gary Miller

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
*************************************************
 

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