I am trying to use method #2 and I've followed the link to successfully have the required fields tagged with "*" automatically show as yellow. However, I can't get the code to correctly work in order to require certain fields like I originally wanted. Every time I delete a require field from an existing field, I get "runtime error 2467." See my code below:
Code:
Private Sub Form_Load()
' Sets background color for required field -> Tag = *
Dim setColour As String
setColour = RGB(255, 244, 164)
Dim ctl As Control
For Each ctl In Form.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Or ctl.ControlType = acListBox Then
If InStr(1, ctl.Tag, "*") <> 0 Then
ctl.BackColor = setColour
End If
End If
Next ctl
Set ctl = Nothing
End Sub
Private Sub myselector_AfterUpdate()
Me.Requery
End Sub
Private Sub SubmitAndClose_DblClick(Cancel As Integer)
Dim ctl As Control
For Each ctl In Form.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Or ctl.ControlType = acListBox Then
If InStr(1, ctl.Tag, "*") & "" = "" Then
MsgBox "Enter data into control. Exit cancelled."
Else
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
End If
End If
Next ctl
Set ctl = Nothing
End Sub