If...ElseIf Statements

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Angelique
    New Member
    • Aug 2006
    • 3

    #1

    If...ElseIf Statements

    All,

    I'm attempting to get Access to return a number on a form field based on input from three different fields. I'm using the code builder to associate the task with the output field. This is what I've written so far with no luck. Any advice you can give will be appreciated.

    Regards,
    Angelique

    Private Sub Task_Priority_A fterUpdate(Canc el As Integer)
    If Task_Difficulty = "1" And Task_Importance = "1" And Task_Frequency = "1" Then _
    Task_Priority = "Training Level 2"
    ElseIf Task_Difficulty = "1" And Task_Importance = "1" And Task_Frequency = "2" Then _
    Task_Priority = "Training Level 1"
    End If
    End Sub
  • beat1078
    New Member
    • Jul 2006
    • 16

    #2
    Why is there an underscore after the THEN in your code example? Also, what are your field types? If they are Number and not Text it will not work.

    --Beattie

    Comment

    • comteck
      New Member
      • Jun 2006
      • 179

      #3
      The underscore simply means that what is on the next line is a continuation of the previous (i.e both lines are really just one line).

      However, Angelique, my question is, can you provide a little more information.

      1. What error messages are you getting?
      2. Is this the entire code for that control? Are "Task_Priority" , "Task_Difficult y", "Task_Importanc e", and "Task_Frequency " actual controls on the form (i.e textbox, combobox, etc)? If they are, then put "Me." in front of them (for example, Me.Task_Priorit y, Me.Task_Difficu lty, etc). If they are not, then they have to be declared in your code, using the DIM statement. For example:

      DIM Task_Priority as Integer

      Let me know.
      comteck

      Comment

      • Angelique
        New Member
        • Aug 2006
        • 3

        #4
        Thanks Beattie and comteck,

        To answer comteck's question, the "Task_Priority" , "Task Difficulty", "Task_Importanc e", and "Task_Frequency " items are textboxes on the form which is associated with a table. The idea is that items are entered into the Difficulty, Importance, and Frequency textboxes on the form and an output is generated in the Priority field. All of the data is simultaneously updated on the table. I haven't made any declarations other than the "AfterUpdat e" one at the top. Thanks again for all of your assistance.

        Regards,
        Angelique

        Comment

        • Angelique
          New Member
          • Aug 2006
          • 3

          #5
          I forgot to include the error message - here it is:

          "The expression After Update you entered as the eveyt property setting produced the following error: Procedure declaration does not match description of event or procedure having the same name. The expression may not result in the maro, the name of the user-defined function, or [Event Procedure]. There may have been an error evaluating the function, event, or macro.

          Thanks Again,
          Angelique

          Comment

          • MMcCarthy
            Recognized Expert MVP
            • Aug 2006
            • 14387

            #6
            Remove the Cancel AS Integer parameter from the AfterUpdate procedure and see if this makes a difference.

            -------------------------------------

            Private Sub Task_Priority_A fterUpdate()
            If Task_Difficulty = "1" And Task_Importance = "1" And Task_Frequency = "1" Then
            Task_Priority = "Training Level 2"
            ElseIf Task_Difficulty = "1" And Task_Importance = "1" And Task_Frequency = "2" Then
            Task_Priority = "Training Level 1"
            End If
            End Sub

            -------------------------------------------

            Just out of curiousity, why are you setting the value of 'Task_Priority' on an AfterUpdate event on 'Task_Priority'

            Comment

            • comteck
              New Member
              • Jun 2006
              • 179

              #7
              Let me ask another question. What are the actual names of the textboxes (i.e when you right-click and select "Properties ", what is the name that appears)?

              comteck

              Comment

              Working...