By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,463 Members | 771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,463 IT Pros & Developers. It's quick & easy.

If...ElseIf Statements

P: 3
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_AfterUpdate(Cancel 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
Aug 8 '06 #1
Share this Question
Share on Google+
6 Replies


P: 16
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
Aug 8 '06 #2

100+
P: 179
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_Difficulty", "Task_Importance", 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_Priority, Me.Task_Difficulty, 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
Aug 8 '06 #3

P: 3
Thanks Beattie and comteck,

To answer comteck's question, the "Task_Priority", "Task Difficulty", "Task_Importance", 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 "AfterUpdate" one at the top. Thanks again for all of your assistance.

Regards,
Angelique
Aug 9 '06 #4

P: 3
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
Aug 9 '06 #5

MMcCarthy
Expert Mod 10K+
P: 14,534
Remove the Cancel AS Integer parameter from the AfterUpdate procedure and see if this makes a difference.

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

Private Sub Task_Priority_AfterUpdate()
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'
Aug 9 '06 #6

100+
P: 179
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
Aug 10 '06 #7

Post your reply

Sign in to post your reply or Sign up for a free account.