Clear form

oxicottin

Learning by pecking away....
Local time
Today, 06:03
Joined
Jun 26, 2007
Messages
888
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
 
Set option button to False unless it is set for TripleState yes.

I would set controls to Null, not empty string.
 
Use Instr() to see if a tag meets the requirement.
 
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
 
But if you have one with Required first as per your original post, that is not going to work?
 
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

Back
Top Bottom