Results 1 to 6 of 6

Thread: If statement

  1. #1
    Join Date
    May 2002
    Posts
    157

    Unanswered: If statement

    Can you please advise what is the correct code to perform the following:

    If [fieldone].value = "Internal Activity" or "External Activity"
    And if [field two] is null
    And if [field three] is null
    And if [field four] is null
    then do something.

    I need to ensure that if the user has chosen "Internal Activity" or "External Activity" then they have entered data into the other three fields.

    Also

    Entering data into only one (or two) of the three fields is not acceptable. Data must be entered into all three fields.

    Can you help me?

    Thanks heaps

  2. #2
    Join Date
    Mar 2006
    Posts
    14
    If [fieldone].value.toString = "Internal Activity" or "External Activity"

  3. #3
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Or maybe

    If (Field1 = "Internal Activity" OR Field1 = "External Activity") AND (IsNull(Field2) Or IsNull(Field3) Or IsNull(Field4)) Then
    Paul

  4. #4
    Join Date
    Mar 2006
    Posts
    14
    you know anything about relational schema baldy you seem to have lots of posts and i am in serious need of help lol

    please see my post and see if you can help me thanks

  5. #5
    Join Date
    May 2002
    Posts
    157
    Thank you to PBaldy

    Your suggestion of the following works exactly:
    If (Field1 = "Internal Activity" OR Field1 = "External Activity") AND (IsNull(Field2) Or IsNull(Field3) Or IsNull(Field4)) Then

    For the Forum I have added my code:

    Private Sub Form_Current()
    On Error GoTo Err_Form_Current_Click

    If Me.NewRecord Then
    'Turn off Label to advise details are required
    Me![InfoReqLbl].Visible = False
    End If


    If (Me.[ActivityType].Value = "Internal Activity/Project" Or Me.[ActivityType].Value = "External Activity/Project") And (IsNull(Me.[ActivityID].Value) Or IsNull(Me.[NameofActvy].Value) Or IsNull(Me.[StartDTofActvy].Value)) Then
    'Turn on Label to advise details are required
    Me![InfoReqLbl].Visible = True

    ElseIf Me.[ActivityType].Value = "Brokered - Host Site" And (Not IsNull(Me.[ActivityID].Value) Or Not IsNull(Me.[NameofActvy].Value) Or Not IsNull(Me.[StartDTofActvy].Value)) Then
    'Turn off Label advising details are required
    Me![InfoReqLbl].Visible = False
    Call MsgBox("PROJECT/ACTIVITY INFORMATION INCONSISTENT WITH ACTIVITY TYPE" _
    & vbCrLf & "" _
    & vbCrLf & """Brokered - Host Site"" does not require Project/Activity Information to be entered." _
    & vbCrLf & "" _
    & vbCrLf & "Check details entered." _
    , vbExclamation Or vbDefaultButton1, "PROJECT/ACTIVITY INFORMATION INCONSISTENT WITH ACTIVITY TYPE")

    Else
    Me![InfoReqLbl].Visible = False
    End If




    Exit_Form_Current_Click:
    Exit Sub

    Err_Form_Current_Click:
    MsgBox Err.Description
    Resume Exit_Form_Current_Click

    End Sub

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    No problem Karen, glad it worked for you.
    Paul

Posting Permissions

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