2 fields, REQUIRED and NON-REQUIRED dates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KMEscherich
    New Member
    • Jun 2007
    • 69

    2 fields, REQUIRED and NON-REQUIRED dates

    Hi there, am wondering if there is a way to have this code capture 2 dates. You see, I have several fields and some are REQUIRED fields and some are NON-REQUIRED fields. I am attempting to capture one date after the REQUIRED fields have been populated and totally different date for the NON-REQUIRED fields after they have been populated. It seems that I am getting one date being populated in both REQUIRED and NON-REQUIRED fields.

    You see, sometimes it takes people several days to capture all the REQUIRED fields or all the NON-REQUIRED fields. Because of this, I need to be sure that I can capture the correct date for both fields.

    Have any ideas on what I can do to correct this??? It would be greatly appreciated if you or someone can show me exactly what I need to do.

    Thank you VERY much for your assistance.



    [CODE=vb]
    Private Sub Form_BeforeUpda te(Cancel As Integer)

    Dim FLAG_2 As Integer
    FLAG_2 = 0


    If Not IsNull(Me.Commu nicated_Date) Then
    FLAG_2 = FLAG_2 + 1
    End If

    If Not IsNull(Me.Descr ibeInjury) Then
    FLAG_2 = FLAG_2 + 1
    End If

    If Not IsNull(Me.BODY_ PART_ID) Then
    FLAG_2 = FLAG_2 + 1
    End If

    If Not IsNull(Me.F_MEA SURES!DATE_COMP L) Then
    FLAG_2 = FLAG_2 + 1
    End If

    If Not IsNull(Me.F_SME _INVEST_TEAM!SM E_NAME) Then
    FLAG_2 = FLAG_2 + 1
    End If

    If Not IsNull(Me.F_SME _INVEST_TEAM!SM E_TITLE) Then
    FLAG_2 = FLAG_2 + 1
    End If

    If Not IsNull(Me.INV_T EAM_REVIEWED) Then
    FLAG_2 = FLAG_2 + 1
    End If

    If FLAG_2 = 7 Then
    Me.DATE_NOT_REQ = Now()
    End If




    Dim FLAG_3 As Integer
    FLAG_3 = 0

    If Not IsNull(Me.SRI) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.LOC_C ODE) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.COST_ CTR) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.INCID ENT_DATE) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.INCID ENT_TIME) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.WEEKD AY_CODE) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.SITE_ LOC_CODE) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.SITE_ AREA_CODE) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.DateR eported) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.TimeR eported) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.INCID ENT_TYPE_CODE) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.Incid entDescription) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.KNOWN _FACTS) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.F_IMM ED_FACTOR_B!IMM _FACTOR_ID) Then
    FLAG_3 = FLAG_3 + 1
    End If


    If Not IsNull(Me.F_KEY _FACTORS!ID) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.Patie ntHandlingFacto r) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.F_MEA SURES!ACTION_ID ) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.F_MEA SURES!DESCRIPTI ON) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.F_MEA SURES!RESPONSIB LE_PARTY) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.F_MEA SURES!TARGET_CO MP_DATE) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.F_MEA SURES!RULE_PROC ) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.F_AUT HOR!AUTHOR_NAME ) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.F_AUT HOR!AUTHOR_TITL E) Then
    FLAG_3 = FLAG_3 + 1
    End If

    If Not IsNull(Me.EMP_I NVEST_TEAM) Then
    FLAG_3 = FLAG_3 + 1
    End If


    If IsNull(Me.DATE_ REQUIRED) Then
    If FLAG_3 = 24 Then
    Me.DATE_REQUIRE D = Now()
    End If
    End If

    End Sub[/CODE]
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    All of this code is run everytime the record is updated, i.e. data is entered/edited. With Line #1 of this code

    [CODE=vb]If IsNull(Me.DATE_ REQUIRED) Then
    If FLAG_3 = 24 Then
    Me.DATE_REQUIRE D = Now()
    End If
    End If
    [/CODE]
    you ensure that DATE_REQUIRED is only populated if it hasn't been populated before.

    The problem is that this code
    [CODE=vb]If FLAG_2 = 7 Then
    Me.DATE_NOT_REQ = Now()
    End If
    [/CODE]
    doesn't do the same thing! If all the Not Required fields are filled in before all the Required Fields, the DATE_NOT_REQ will be re-populated each time a Required Field is populated.

    Emend this piece of code to read

    [CODE=vb]If IsNull(Me.DATE_ NOT_REQ) Then
    If FLAG_2 = 7 Then
    Me.DATE_NOT_REQ = Now()
    End If
    End If
    [/CODE]and this date will only be populated once.


    Linq ;0)>

    P.S. When you use code tags such as [Code = VB] you have to make sure that there are no spaces between the square braces. It has to be Code=VB.

    Comment

    Working...