Operation to Clear a Form?

KristenD

Registered User.
Local time
Today, 07:28
Joined
Apr 2, 2012
Messages
394
I have a form that uses a query to run reports. Is there an operation for a button to clear the form? When it starts the wizard there is no option for clearing the data, just refreshing. They are all unbound combo boxes that I have in the form.

I don't need to save any records as this form is used solely for reporting purposes.
 
I have a form that uses a query to run reports. Is there an operation for a button to clear the form? When it starts the wizard there is no option for clearing the data, just refreshing. They are all unbound combo boxes that I have in the form.

I don't need to save any records as this form is used solely for reporting purposes.

There isn't a magic "clear form" button. However, you can place a button on your form and use the following code as the OnClick event...

Code:
    Dim Response As Integer
    Response = MsgBox(prompt:="Are You Sure?", Buttons:=vbYesNo)
    If Response <> vbYes Then Exit Sub
    Me.firstbox = Null
    Me.secondbox = Null
    Me.thirdbox = Null
    Me.optiongroup = 1
    Me.whereyouwanttoputthecursor.SetFocus

And obviously, you substitute whatever names you gave your text boxes in the form in the code. Feel free to take out the option group if you don't have one.
 

Users who are viewing this thread

Back
Top Bottom