VBA Code for IIf statement (1 Viewer)

Dscalf1

Registered User.
Local time
Today, 12:14
Joined
Jul 17, 2015
Messages
33
Is there anyway to use the After Update feature to write a VBA code for an IIf statement...

Im trying to store the value of a field that gives me a number based on which radio button is pushed and it seems that absolutely no one has heard of this...
 

vbaInet

AWF VIP
Local time
Today, 19:14
Joined
Jan 22, 2010
Messages
26,374
I explained how you do it using an Update Query.
 

plog

Banishment Pending
Local time
Today, 14:14
Joined
May 11, 2011
Messages
11,611
Is there anyway to use the After Update feature to write a VBA code for an IIf statement...

That doesn't make the most sense. I mean you can put any VBA code on an After Update event. So to answer your question, yes. In the property dialog, you go to the AfterUpdate event, click on the elipses, select the Code option, it opens a window and you write your code.



Im trying to store the value of a field that gives me a number based on which radio button is pushed

I read your other post and there as well as here I am confused why you are married to using radio buttons. In both posts it sounds like you simply need a drop down. What do radio buttons do for you that a drop down won't? With drop downs you can have the added benefit of the value selected being automatically saved to the underlying table of the form.
 

Dscalf1

Registered User.
Local time
Today, 12:14
Joined
Jul 17, 2015
Messages
33
I read your other post and there as well as here I am confused why you are married to using radio buttons. In both posts it sounds like you simply need a drop down. What do radio buttons do for you that a drop down won't? With drop downs you can have the added benefit of the value selected being automatically saved to the underlying table of the form.

Im not married to anything. No one has every said anything about a drop down box until now, and I havent even thought of that..

If I were to use a drop down box how do I get the value from it to be subtracted from the section total? Im pretty sure I can use a query for that but would I have to save the values in the dropdown box in a different table first and then use them in the query?

This has been the most helpful post in two days then everybody telling me you shouldnt do it that way you shouldnt save calculated values.. You actually gave me a suggestion on what else to do.
 

plog

Banishment Pending
Local time
Today, 14:14
Joined
May 11, 2011
Messages
11,611
The "don't store calculated values" rule is actually "don't store redundant data" rule. There's a difference. I'm unclear on what exactly you are storing. Are you storing just the total? Or are you storing the individual values that comprise the total as well as the total?

If you are just storing the total and not the underlying values, then it is fine to store the total (just know you won't have the individual values later on). If you are storing the underlying values that go into the total, then no, you shouldn't store the total, instead you should calculate it with the underlying values.

Again, I'm unclear what you are storing. Are you storing underlying, individual values or do you just care about the total?
 

Dscalf1

Registered User.
Local time
Today, 12:14
Joined
Jul 17, 2015
Messages
33
So in scoring a bread loaf there are 12 different sections each allotted an amount of points. Those points add up to 100 (total score). Now if something is wrong in any section there are deductions that get deducted from the sections score. and then all sections scores are summed and given a total score.

Now what I need to store is each sections score and then the final score. (I have no say so in this it is how corporate wants the data sent) I figured radio buttons would be the most user friendly as I didnt want the numbers shown I wanted to deductions in three ranges poor, medium, and good.

I am open to any possible way to do this.. I dont know how to upload a picture I have tried before or I would show yall what I am trying to do any way possible :(
 

plog

Banishment Pending
Local time
Today, 14:14
Joined
May 11, 2011
Messages
11,611
In that case you don't store the final score, you store the section score and calculate the final. This means the scoring table should look something like this:

BreadScores
Score_ID, autonumber, primary key of this table
ID_Loaf, number, foreign key to loaf table
ID_ScoreType, number, foreign key to scoring table to identify what section this score is for.
Score_Deduction, number, this is the value the user supplies to say how much to deduct from score.

Does your table vaguely resemble that? If not, post a screenshot of your tables. To do that, click on the 'Go Advanced' button under the place where you type in your comments, then go to the 'Manage Attachments' button on the bottom of the page you are taken to and then select a file to upload.
 

Users who are viewing this thread

Top Bottom