Clear form (1 Viewer)

oxicottin

Learning by pecking away....
Local time
Today, 07:51
Joined
Jun 26, 2007
Messages
850
Hello, I have two questions....

1) I need to use the Tag property to clear my form and that's not a problem. The problem is a few text boxes already have a name in it that's used for verifying data. Can I use two tag names for one control? If so how would I enter it? this didn't work.... (Required, ClearMe)

2) I have a few option buttons I need to untick so how would I add that to my code below?


If Me.optMon Or Me.optTues Or Me.optWed Or Me.optThurs Or Me.optFri Or Me.optPaperLift = True Then
Dim ctl As Control

For Each ctl In Me.Controls
With ctl
Select Case .ControlType
Case acTextBox, acComboBox, acListBox, acCheckBox
If .Tag = "ClearMe" Then
ctl.Value = ""
End If
End Select
End With
Next ctl

End If
 

June7

AWF VIP
Local time
Today, 03:51
Joined
Mar 9, 2014
Messages
5,399
Set option button to False unless it is set for TripleState yes.

I would set controls to Null, not empty string.
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:51
Joined
Sep 21, 2011
Messages
13,965
Use Instr() to see if a tag meets the requirement.
 

oxicottin

Learning by pecking away....
Local time
Today, 07:51
Joined
Jun 26, 2007
Messages
850
Thank you all!!! I got it working... instead of using the Instr() I just added the 3 controls at the bottom to clear.

Code:
If Me.optMon Or Me.optTues Or Me.optWed Or Me.optThurs Or Me.optFri Or Me.optPaperLift = True Then
    Dim ctl As Control
    
    For Each ctl In Me.Controls
        With ctl
            Select Case .ControlType
            Case acTextBox, acComboBox
                If .Tag = "ClearMe" Then
                    ctl.Value = Null
                    End If
            Case acOptionButton
                If .Tag = "ClearMe" Then
                    ctl.Value = False
                End If
            End Select
        End With
        Next ctl
    End If
    
    Me.txtDateVWIReviewed = Null
    Me.txtDateSOCReviewed = Null
    Me.txtDateLOTOReviewed = Null
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:51
Joined
Sep 21, 2011
Messages
13,965
But if you have one with Required first as per your original post, that is not going to work?
 

oxicottin

Learning by pecking away....
Local time
Today, 07:51
Joined
Jun 26, 2007
Messages
850
It works, the Three text boxes that have the tag "required" I didn't add a second tag I just used

Me.txtDateVWIReviewed = Null
Me.txtDateSOCReviewed = Null
Me.txtDateLOTOReviewed = Null
 

Users who are viewing this thread

Top Bottom