Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Mar 2003
    Location
    Summerville, South Carolina, USA
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If...then (Access 2000)

    (Edited by HansV to insert space between [ and training.)

    This is probably pretty simple, but I am trying to do an if..then statement with a close button. The database is simply a survey and if they choose a 1 or 2 (low score) they must fill in the comments pertaining to that score. Here is the code...

    Private Sub cmdCloseFrom_Click()
    On Error GoTo Err_cmdCloseFrom_Click

    If [ManualEasyToRead] < 3 Or [ManualWellOrganized] < 3 Or [ManualPolicyClarifications] < 3 _
    And IsNull([Comments]) Then
    MsgBox ("You must fill in the comments because a score relating to the Online Claims Manual was 1 or 2")
    ElseIf [PacketEasytoRead] < 3 Or [PacketWellOrganized] < 3 Or [PacketMaterialClear] < 3 _
    And IsNull([PacketsComments]) Then
    MsgBox ("You must fill in the comments because a score relating to the Training Packet was 1 or 2")
    ElseIf [WorkbookClearDirections] < 3 Or [WorkbookHelpful] < 3 Or [WorkbookVariety] < 3 _
    And IsNull([WorkbookComments]) Then
    MsgBox ("You must fill in the comments because a score relating to the Workbook Materials was 1 or 2")
    ElseIf [ TrainerKnowledge] < 3 Or [ TrainerAbilityQuestions] < 3 Or <trainerConveys> < 3 _
    Or [ TrainerPrepared] < 3 Or [ TrainerProfessional] < 3 Or [ TrainerAvailabilty] < 3 _
    Or [ TrainerAdditionalMaterials] < 3 Or [ TrainerSupplied] < 3 And IsNull([ TrainerComments]) Then
    MsgBox ("You must fill in the comments because a score relating to the Trainer was 1 or 2")
    Else
    DoCmd.Close

    End If

    Exit_cmdCloseFrom_Click:
    Exit Sub

    Err_cmdCloseFrom_Click:
    MsgBox Err.Description
    Resume Exit_cmdCloseFrom_Click

    End Sub

    It is not working. Like I said, it is probably something real small, but any help would be appreciated.

    Thanks.

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: If...then (Access 2000)

    What do you mean by "it isn't working"? Do you get an error or what?

    One thing you might do to make your statements more readable (and to avoid any possible logic confusion) is to use parentheses to isolate the variable segments of your If statements.

    For example, instead of:
    if conditionA or conditionB or ConditionsC and ConditionD then

    You might use this (if this is the correct interpretation):
    If (ConditionA or ConditionB or ConditionC) and ConditionD then
    [
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: If...then (Access 2000)

    For some reason unknown to me, the HTML parser gobbled up the field names in square brackets starting with Training. I inserted a space to prevent that.

    The cause of your problem is probably that And has precedence above Or in expressions, so you need to use brackets like this:

    If ([ManualEasyToRead] < 3 Or [ManualWellOrganized] < 3 Or [ManualPolicyClarifications] < 3) _
    And IsNull([Comments]) Then

    and similarly for the other conditions.

Posting Permissions

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