clear unbound form

odun

Registered User.
Local time
Today, 00:40
Joined
Apr 24, 2005
Messages
108
Hello all,

Need your help again.

I have an unbound form with text boxes and 1 check box.

I created a module named Reset;

Private Sub Reset()


[Sales].Value = ""
[Corporate].Value = ""
[EndDate].Value = ""


End Sub

1) I linked this module to a macro so that on clicking a button, the macro runs the module and closes it, but it's not working.
in my macro, I have open module: Reset
I also have clode module= Object: Module, Name: Reset
But this is not working

2) Also, how do I clear the check box?

Thanks again for the help.
 
Put this code behind a command button called cmdClearAll

Code:
' Clear All TextBoxes and Set all Check boxes to false (no tick)
Dim ctl As Control
For Each ctl In Me.Controls
    If ctl.ControlType = acTextBox Then
        ctl.Value = ""
    ElseIf ctl.ControlType = acCheckBox Then
        ctl.Value = False
        
    End If
Next ctl
Set ctl = Nothing
 
Thanks John A,

I tried pasting the code you provide in my existing button and changed the name of the button, but the code is not working. So, I tried creating a new button, but I am getting an error:
Commandbutton Wizard: compile error in query expression 'ApploadString[bw_tbltnActions]Description). Do you know why?
 
When you add the button to your form DON'T use the wizard.

Attached is a sample, have a look at the code behind the command button and you will see that the code I posted works.

Let me know how it goes.
 
Last edited:
Hi, could you walk me through how to add the code to the button, I thought I had to use the wizard to do that, thanks again.
 
Thanks a lot, it worked perfectly!!!

ansentry said:
When you add the button to your form DON'T use the wizard.

Attached is a sample, have a look at the code behind the command button and you will see that the code I posted works.

Let me know how it goes.
 
Glad we go it to work, thanks for your reply.
 

Users who are viewing this thread

Back
Top Bottom