Reset Command for text boxes (To 0)

saqibawr

Registered User.
Local time
Today, 07:25
Joined
Oct 3, 2008
Messages
27
I have Created a receipt based on database. Now with command button i am able to reset all combo boxes in form but i am unable to reset all text boxes to 0. (Default Value).

Can any one help me by creating a code that 0 value come in all the boxes of form along with resetting all the combo boxes.
 

Attachments

Your problem is that your text boxes are unbound and are calculated - this requires a bit of a tweak since you can't set the it to 0. Instead of two command buttons - do it all in one with the select case statement ....

Code:
    Dim ctl As Control
 
    For Each ctl In Me.Controls
        Select Case ctl.ControlType
        Case acComboBox
            ctl.Value = Null
        Case acTextBox
            If (Left$(ctl.ControlSource, 1) <> "=") Then
                ctl.Value = Null
            ElseIf (Len(Trim$(ctl.ControlSource & vbNullString)) = 0) Then
                ctl.Text = 0
            End If
        End Select
    Next

-dK
 
This command is resetting all the values to null. When all the values are null it does not show the total. I want to reset all values to 0.
 
Code:
Dim ctl As Control
 
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acComboBox
ctl.Value = Null
Case acTextBox
If (Left$(ctl.ControlSource, 1) <> "=") Then
ctl.Value = 0
 
ElseIf (Len(Trim$(ctl.ControlSource & vbNullString)) = 0) Then
ctl.Text = 0
End If
End Select
Next
 
You betcha ....

Good luck with your project!

-dk
 

Users who are viewing this thread

Back
Top Bottom