Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2002

    Unanswered: How to check required property in code


    I'm trying to customize error message that Access displays when required fields contain no data and set focus to the first empty control on the form with "required" set to true.

    Here is my code:

    Private Sub cmdSave_Click()
    On Error GoTo cmdSave_Err
    Select Case Err.Number
    Case 3314
    MsgBox "To create a new record fields ""RPA Number"", ""Division Number"", ""Date Sent to PSS"" must contain values", vbExclamation, _
    "Data Entry Error"
    DataEntryError Me
    End Select
    Resume Exit_cmdSave_Click
    End Sub

    Public Sub DataEntryError(frmActive As Form)

    Dim recClone As Object
    Dim ctr As Control
    Set recClone = frmActive.RecordsetClone

    For Each ctr In frmActive.Controls
    If TypeOf ctr Is TextBox Or TypeOf ctr Is CheckBox _
    Or TypeOf ctr Is ComboBox Then
    If ctr.Required And IsNull(ctr.Value) Then
    End If
    End If
    Next ctr
    End Sub

    When I run this, the code stops at the red line with the mes.: Object doesn't support this property or method, #438

    How can I check for the required property of a control in this case?
    Thank you in advance.

  2. #2
    Join Date
    Feb 2002
    If ctr.Required And IsNull(ctr.Value) Then

    if ctr.value="" or IsNull(ctr.value) then

    Where is the required property on the control? If you have placed it in the tag then:

    if ctr.tag="Required" then

    if IsNull(ctr) then

  3. #3
    Join Date
    Apr 2002


    Hello dynamictiger,

    Thanks. It works fine with tags. In fact, I've never used this property before, and even didn’t know what it's for.

    I appreciate your help a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts