Error when clearing form

Turbo910

Registered User.
Local time
Today, 17:05
Joined
Nov 8, 2009
Messages
43
Hi guys

Basically i have created a form (Majority unbound) and wanted the user to be able to save the form (done) and then clear the form in order to input the new data.

I already have a clear button that clears a majority of the controls on the form using this VBA code

Private Sub Clear_form_Click()
Dim ctl As Control

On Error Resume Next

For Each ctl In Me.Controls
ctl.Value = ctl.DefaultValue
Next

Set ctl = Nothing

End Sub

This is all well except one point :

The last text box doesn't clear, instead it says #Error. The Text box is simple i just created it from the MS ribbon and entered the name of it and a simple calculation which is : =[Quantity]-[Quantity_out].

this obviously means that not all the controls are clear and new so How exactly do i over come this??

Anything else i can do please ask

Thankyou!!
 
The last text box doesn't clear, instead it says #Error. The Text box is simple i just created it from the MS ribbon and entered the name of it and a simple calculation which is : =[Quantity]-[Quantity_out].

What is the default value of Quantity and Quantity_out, my guess is that one or both has a default value of NULL aka empty. Make sure that these controls is numeric and has a default value of 0.

0-0=0 but 0-NULL=#error

Hope this helps

JR
 

Users who are viewing this thread

Back
Top Bottom