Calculate fields.

john527

Registered User.
Local time
Today, 03:16
Joined
Jul 9, 2006
Messages
36
Hi, can someone help me with this formula.

i have one field called notice_1 this field is a combo boxs multiple choice ( YES - NO )
Then i have 1 field called score_1 ( if notice_1 = "YES" then let score_1 = 5 else then let score_1 = 10 )


Does this make sense , I am an, amateur at access 2003,

Thank You For any help i can get...

John Calcitrai
 
In the After Update event of the combo box, put

Code:
If [forms]![[I]form name[/I]]![notice_1] = "YES" Then

         [forms]![[I]form name[/I]]![score_1] = 5

Else

         [forms]![[I]form name[/I]]![score_1 = 10

End If
 
Not Working ?

Thank you for your help, but where do I put this code at, in control source, default value, validation rule. Also I understain [form name] this would be the name of my form, but I do not understain [forms] ???
I put the code in properties / control source, save the code, then go back and open the form to test the code and it is not there / Gone did this 5 times and with the same results.

Can you help me

John Calcitrai
 
[Forms]! means just that. It tells the code to look for a form named whatever you called it, as opposed to a report or a query, etc.

If you found the Control Source area, you're looking in the right place. On the Event tab, there's a row called After Update. You need to click on this row to select it, then on the three dots that will appear to the right of the row. Choose the Code Builder option and place the code shown in the window that you will see (it will default to the After Update event of that control).

Now, when you update the Combo Box, the AfterUpdate event will be told to run the code you just added.

Hope that makes more sense.
 
Still Not Working.

Hi Matt, I did just like you said to the letter, and when i ext the code, and ext the form, i go back & open the form up to test the code, Nothing no response. I go back to check the code and it looks ok. See for your self.

Private Sub cust_credit_score_1_AfterUpdate()
If [Forms]![Customer Form]![cust_credit_repy_1] = " Bad Credit" Then
[Forms]![Customer Form]![cust_credit_score_1] = 10

Else
[Forms]![Customer Form]![cust_credit_score_1] = 5

End Sub

Thank you for your help it is appreciate time & time again

John Calcitrai...
 
1) Try the following, to test if the value from the combo box is being read correctly:

Private Sub cust_credit_score_1_AfterUpdate()

Code:
If [Forms]![Customer Form]![cust_credit_repy_1] = " Bad Credit" Then

Msgbox "10"

Else

Msgbox "5"

End Sub

If you see the 5 and 10 values displayed when you expect to, then that part of the code is working correctly. If so, try

Code:
[Forms]![Customer Form]![cust_credit_score_1].[B]Value[/B] =

instead of

Code:
[Forms]![Customer Form]![cust_credit_score_1] =

2) Should there definitely be a space before "Bad Credit"? If not, once we get this working, you'll always get 5 as the result.
 

Users who are viewing this thread

Back
Top Bottom