Solved Exercises for if elseif else ...

lacampeona

Registered User.
Local time
Today, 13:05
Joined
Dec 28, 2015
Messages
392
Hello experts
I need some help.

Can someone who has a time prepare me some 5 difficult problems or more or some good example in which I will have to practice:




Example something like that


Sub ShouldIGoOutToday()
'Set the weather to good or bad
Good_Weather = False
'Set the Rain coat to ready or not
Rain_Coat_Ready = True
'Set the type of bad weather
Bad_Weather = "Some Rain"
If Good_Weather = True Then
'if weather is good then go out
MsgBox "Go Out"
Else
'if weather is not good
If Bad_Weather = "Some Rain" Then
'If the bad weather is some rain
If Rain_Coat_Ready = True Then
'If the bad weather is some rain and the rain coat is ready
MsgBox "Go Out"
Else
'if the bad weather is some reain and the rain coat is not ready
MsgBox "Stay Home"
End If
ElseIf Bad_Weather = "Blizzard" Then
'if the bad weather is blizzard
MsgBox " Stay Home"
End If
End If
End Sub

Sub ShouldIGoOutTodayEx2()
'Set the weather to good or bad
Good_Weather = False
'Set the Rain coat to ready or not
Rain_Coat_Ready = True
'Set the type of bad weather
Bad_Weather = "Some Rain"
If Good_Weather = True Then
'if weather is good then go out
MsgBox "Go Out"
Else
'if weather is not good
If Bad_Weather = "Some Rain" And Rain_Coat_Ready = True Then
'If the bad weather is some rain AND the rain coat is ready then Go Out
MsgBox "Go Out"
ElseIf Bad_Weather = "Blizzard" Or Rain_Coat_Ready = False Then
'if the bad weather is blizzard or the rain coat is not ready then Stay Home
MsgBox " Stay Home"
End If
End If
End Sub


Or If someone has a good articles so I can read and study.
Or if someone can explain me...or where I can search for more

Is that the correct order?
1. if
2. else if
3. else
4. end if
5. else
6. end if


I know that is a basic but I just have a feeling that I need to practice that more.
thank you very much
 
Don’t have examples but you can Google to find plenty of tutorials- here is an example
 
With complex "if" operations, I prefer using the "case statement". The "case statement" is easier to interpret when compared to a complex "if statement". Additionally, the "case statement" has the "case else" option that is beneficial to throw an error message should there be a logical test that was missed or improperly constructed.
 
+1 vote for using a case statement in place of ElseIf's. It's so much easier to read and debug.
 
As an aside, in a query, using the switch function is the equivalent of a Case statement and better than using nested iif’s. Switch can be used in vba - but generally easier to use Case
 
In your 6-member list in post #1 of this thread, item 4 precludes the use of the later elements.

An IF statement creates an IF block. Oddly enough, so does an ELSE or ELSEIF. A block is also created by FOR / NEXT or DO / LOOP or any of the other looping methods. An ELSE, ELSEIF, or END IF terminates the previous IF-type block. Limiting ourselves to IF-blocks, you have a general form

Code:
IF <Y/N expression>
    THEN
        TRUE-case... a block of things to do if your expression evaluates to TRUE
    ELSE
        FALSE-case... a block of things to do if your expression evaluates to FALSE
END IF

You cannot put a label in either the TRUE case or FALSE case and jump into the block, though there are many ways to get out of the block. You can omit the ELSE and the FALSE-case block if needed. You can also omit the TRUE-case block but cannot omit the keyword THEN.

Adding ELSEIF into the mix is limited in certain ways...

Code:
IF <Y/N expression #1>
    THEN
        TRUE-case block #1
    ELSEIF <Y/N expression #2>
        TRUE-case block #2
    ELSE
        FALSE-case block #3
END IF

If you do this, there is only ONE ELSE and it is only executed if neither of expression #1 and #2 are true. Again, it is forbidden to jump into any of those blocks, though you can put a fully contained IF-block inside. Then you have to treat IF and END IF as parentheses that need to be matched.

Code:
IF <Y/N expression #1>
    THEN
        TRUE-case block #1
        IF <Y/N expression #2>
            THEN
                TRUE-case block #2
            ELSE
                FALSE-case block #3
       END IF
       now back in TRUE-case block #1 again!!!!
       ELSE
            FALSE-case block #4
END IF

I believe that IF-nesting is limited in depth but it is rare to run into that limit. This case is different than the ELSEIF case. If you want to think of it this way, in the ELSEIF case you get to FALSE-case block #3 if and only if Y/N expression #1 AND Y/N expression #2 are FALSE. In the nested IF case, you get to TRUE-case block #2 if and only if Y/N expression #1 AND Y/N expression #2 are TRUE.

As a matter of my opinion, if you have an urge to write ONE ELSEIF, it might be OK. If you have an urge to write TWO OR MORE ELSEIF statements in the same overall code sequence and related to the same initial IF statement, use a CASE statement instead. ELSEIF "ladders" are harder to read.
 
Hello experts
ohhh I see. So you reccomend to use case statments.
So that mean that in your coding you use 80% case statments and 20% elseif?
I was trying to read some code with elseif statments and I get lost, so I start thinking that maybe I am not good in that. :unsure:
Becouse of that I start thikining what is better to use.
Thank you very much for your opinion.
 
Hello Pat,
yes sorry if I say wrong. I was thinkinig that is better to use select case then if -elseif-elseif-statments?
I know that if -then -else is almost everywhere.
Can I ask another question?

If you have to check 8 statments how would you start?
1. if
2. elseif
3.elseif
4.elseif
5. elseif
6.elseif
7.elseif
8.elseif
9. end if?
I dont know but this elseif is making me probelms when reading all my disaster...


I have to check 8 statments for some combo box field. Is correct to use the code on click event or on before update of the field?
For now I have the code on click event.

How do I know on which event to put the code? I know that must be some rules ...from you experts I learn that for validation rules is best to use before update event on the form...
 
Agree with Pat.

If you have to check 8 statments how would you start?

95% of the time I would use a Select Case because although its 8 statements, its most likely just one variable tested against 8 values.

A=1
A=2
A=3
...
A=8

Sometimes though, the tests aren't that simple or complete:

A=1
B="Blue"
A=72 AND C<1/1/2022
B="Red"
A=9 AND B="Green" AND C>1/1/2022

I would make each of those an If statement (without an else).
 
I will write what is my problem.

I have to check 8 different conditions. I have very very complicate database. I need some example from you experts so I will know and learn how to do that in my form.
Before reading all my disaster of coding...(I know that I need to practice more if elseif statments) I will explain what I want to achieve.


Translation:
1. Redna Analiza = Regular analysis
2. Namen Uporabe = Purpose of testing (this is combo box, with 4 options), Regular analysis-Release analyis-Testing analysis,Changing status.
3. Sproščanje = Release analyis
4. TestaAnaliza = Testing analysis
5. SpreminjanjeStatusa = Changing status
6. Status = status of the record, it can be entered or approved. If it is empty this mean that user did not yet signed the record.
7. StatusKolone = StatusItem in this case is important status release
8. (3) Sproscena = (3) Released
9. SproscanjeUstrezno = ReleasedSucceful, options YES, NO and N/A.
10. DA = YES
11. NE = NO
12. N/A = N/A

I have two tables.
1. table (tblKolone2) and her subform frmVnosKolone
(In this table user enter specific information about some items)
2. table (tblUporabaKolon) and her subform frmKoloneUporabaSUB
(In this table user enter specific information about usage of the item, status item, date/time of usage, notes...)


Before user will start performing anaylsis on the item he can make analysis on item that is not released (before) yet and then he can and will start making analsis (after) releasing the item, that mean the the item is released and he can make analysis on released item.
So i was thinking that way. Before releasing the item he can try to use 4 options ( Regular analysis-Release analyis-Testing analysis,Changing status.) and then he can use the relased item again with 4 options ( Regular analysis-Release analyis-Testing analysis,Changing status.)
I need to block the next
1. if item is released he can not perform again the relased analysis
2. if the item is not released he can not do regualar analysis
3. if the item is not released he can try ( Regular analysis-Release analyis-Testing analysis,Changing status.)
4. if item is relased he can try ( Regular analysis-Release analyis-Testing analysis,Changing status.)

For approving that each record has the correct data I am using signatures. With signatures I mean that I have some sign off form on which analyst enter his name and his password and he sign the record. Then approver login, check if all the data is correct in the specific record and he also enter his name and his password and he approve the record. When the record is approved all the data is locked. Nobody can change data anymore. The record gets his status to approved. If record is not approved is empty field, if is only signed by analyst the record has status entered.


This mean that when analyst will do some measurments he will sign each record.
Record must have 2 signatures. One from the analyst and second for the approver. First line of signature is entered, second line is approved.
Every record in table tbl2, tblUporabaKolon must be approved before user will perform regualar analysis.

In the beggining I say that I have two forms.
When analyst make measurments he use second form frmUporabaKolonSUB and the connected table is tblUporabaKolon.

But before analyst can perform regular analyis he must make one special analysis called Release anaylsis. With that release analysis he will confirm that the selected item is good and prepared for doing the regular analysis then on daily basis.

When analyst will make relase analysis the status of the item will change to status release in my case (3) Sproscena.
Only if the item will have the status (3) Sproscena analyst will be alloved to go to the regualar analysis.

But before he can go to the regualar analyis he has to have some signatures that will confirm that all data is correct and the items is prepared to be used.

With form one, frm VnosKolone and connected table table tblKolone2 analyst and approver confirm that all the data entered for that item is correct, that the item contains valid certificate of anaylsis. This form also must be signed and also must have 2 signatures. From the analyst and from the approver.

So I need to achieve that both forms frmVnosKolone and specific record ID from the tblUporabaKolon on which release analysis was made must have signatures approved.

If first form is not approved and the release analysis is approved analyst can not go to the regualar analis. He must signed the record from tblUporabaKolon. that mean that status signature approved from tblKolone2 and the status signature approved must both be signed with approved.

if the form frmVNosKolone with his specific ID is signed and then if the release analysis with the specific ID is signed then analyst can go and make some regular analysis.

I start thinking how to check all that conditions and use Dcount to find what I need.
I hope can somebody read my disaster and tell me what I am doing wrong and how I have to make that correct.
thank you very much


Private Sub NamenUporabe_Click()
If Me.NamenUporabe = "TestnaAnaliza" Then
Me.SproscanjeUstrezno = "N/A"
ElseIf Me.NamenUporabe = "SpreminjanjeStatusa" Then
Me.SproscanjeUstrezno = "N/A"
Me.OznakaInstrumenta = "N/A"
Me.AnalitskiPostopek1 = "N/A"
Me.AnalitskiPostopek2 = "N/A"
Me.Analiza1 = "N/A"
Me.Analiza2 = "N/A"
Me.EmpChromChemMapa = "N/A"
Me.RefNaAnalizo = "N/A"
Me.StranStevilka = "N/A"
Me.RaztopinaIzpiranje = "N/A"
Me.CasIzpiranja = "N/A"
Me.SteviloInjiciranj = "0"
Me.AnalizaUstreza = "N/A"
End If

If Me.NamenUporabe = "RednaAnaliza" Then
Dim criteria1 As String
Dim criteria2 As String
Dim criteria3 As String
Dim criteria4 As String
criteria1 = "[SproscanjeUstrezno] = 'DA' AND [KID] = " & Me.KID
criteria2 = "[SproscanjeUstrezno] = 'DA' AND [KID] = " & Me.KID
criteria3 = "[status] = 'approved' AND [KID] = " & Me.KID
criteria4 = "[SproscanjeUstrezno] = 'DA' AND [KID] = " & Me.KID


If DCount("*", "tblUporabaKolon", criteria1) = 0 Then
MsgBox "Sproscanje ni bilo izvedeno.Prosim izvedite analizo sproščanja.Ta zahteva ni mogoča in bo zavrnjena."
Me.Undo
DoCmd.Close acForm, "frmKoloneUporabaSUB"
End If

ElseIf Me.NamenUporabe = "Sproščanje" Then
If DCount("*", "tblUporabaKolon", criteria2) > 0 Then
MsgBox "Ponovno želite izvajati analizo sproščanja, čeprav je bilo Sproščanje že ustrezno. Ta zahteva ni mogoča in bo zavrnjena."
Me.Undo
DoCmd.Close acForm, "frmKoloneUporabaSUB"
End If
End If
End Sub

Private Sub NamenUporabe_BeforeUpdate(Cancel As Integer)

If Me.StanjeSproscanja = "(3) Sproscena" And Me.NamenUporabe = "TestnaAnaliza" Then
Me.StatusKolone = "(3) Sproscena"
Me.SproscanjeUstrezno = "DA"
Me.StatusKolone.Enabled = False
Me.SproscanjeUstrezno.Enabled = False
ElseIf Me.StanjeSproscanja = "(3) Sproscena" And Me.NamenUporabe = "SpreminjanjeStatusa" Then
Me.SproscanjeUstrezno = "DA"
Me.OznakaInstrumenta = "N/A"
Me.AnalitskiPostopek1 = "N/A"
Me.AnalitskiPostopek2 = "N/A"
Me.Analiza1 = "N/A"
Me.Analiza2 = "N/A"
Me.EmpChromChemMapa = "N/A"
Me.RefNaAnalizo = "N/A"
Me.StranStevilka = "N/A"
Me.RaztopinaIzpiranje = "N/A"
Me.CasIzpiranja = "N/A"
Me.SteviloInjiciranj = "0"
Me.AnalizaUstreza = "N/A"
ElseIf Me.StanjeSproscanja = "(3) Sproscena" And Me.NamenUporabe = "RednaAnaliza" Then

Dim criteria3 As String
Dim criteria4 As String
criteria3 = "[status] = 'approved' AND [KID] = " & Me.KID
criteria4 = "[SproscanjeUstrezno] = 'DA' AND [KID] = " & Me.KID

If DCount("*", "tblKolone2", criteria3) > 0 And DCount("*", "tblUporabaKolon", criteria4) > 0 Then

Me.StatusKolone = "(3) Sproscena"
Me.SproscanjeUstrezno = "DA"
Me.StatusKolone.Enabled = False
Me.SproscanjeUstrezno.Enabled = False
MsgBox "Analiza Sproščanja je bila izvedena vendar ni podpisana.Prosim podpišite analizo Sproščanja.Vaša zahteva bo zavrnjena."
DoCmd.Close acForm, "frmKoloneUporabaSUB"
End If
End If
End Sub
 
I am total amateur in ms access database. I learn a lot from this forum and a lot of internet.
Yes I know Pat that I Have to practice if then else this is basic and i am like stupid..

I am just confused with elseif. I was using if-then-else in another situations and on this problem I start thinking of that elseif amd select case and how to do that.

Yes I am sorry if I write so complex question. I just need some example how to learn and to check if what I make for now is going in correct way or not.
thank you for your reply and I will watch your video.
Thank you
 
You used the word "Translation" in your question. If this is a simple field that can have ONE value from of a list of values AND whatever this list translates for you is always and only single-valued (not "single word" because phrases are allowed in translation, but single-valued), then EITHER use a CASE statement OR create a JOIN to a table where the field in question links to a translation table - at which point you just pick up the translation directly with no other decisions.

In the case of translating a single field to a single value, I would NEVER use an ELSEIF ladder. I would RARELY use CASE. My preferred choice would always be a JOIN to a translation table. The only time I might use an ELSEIF would be with very limited logic where you are not looking at only one field in all cases. While ELSEIF is perfectly legal, that doesn't make it optimum syntax.
 
Yes I will put like you say. I will batlle with if statments again tomorrow and on for the weekend so I will came back to inform you what disaster i will create.


ohhh :oops: I am so embarased for my coding and my stupid questions.

You are all experts and me nothing.. :(

DocMan i will also try your suggestion: but how i have to create JOIN to a translation table?
hmm I never to that?do you have some example how to make that?

I will try both suggestions.

thank you
 
DocMan

Yes I make a list of words from my language so you can know what word mean sometthing.
I think the translation was for our benefit so we knew what the words meant.
 
but how i have to create JOIN to a translation table?
A translation JOIN looks SOMETHING like this:

PersonTable: PersID, PersFirst, PersMid, PersLast, Addr1, Addr2, City, StateAbbrev
PersID is the primary key and StateAbbrev is the 2-letter postal abbreviation.

StateTable: StateAbb, StateLong
StateAbb is the primary key (natural, not a synthetic key) and example records might be "LA, Louisiana" or "KS, Kansas" or "TX, Texas"

Then

Code:
SELECT P.PersID, P.PersFirst, P.PersMid, P.PersLast, P.Addr1, P.Addr2, P.City, S.StateLong
FROM PersonTable P INNER JOIN StateTable S ON P.StateAbbrev = S.StateAbb ...

This would use the state abbreviation in the PersonTable to look up the state's long name from the StateAbbrev table using the method of a table JOIN to accomplish the lookup. The above is a VERY SIMPLE translation lookup JOIN and does not include safeguards for bad data.
 
ElseIf is a variation of the Else statement that originated prior to the Case statement. If you have something that can be implemented with a Case, in the OLDEN days, prior to the advent of the Case statement, the ElseIF was a more compact way of expressing the conditions because it didn't require indentation and allowed you to code something that was mutually exclusive rather than dependent in a more visually pleasing way.

Now that we have the Case statement, ElseIf has outlived its usefulness. Use the Case for mutually exclusive conditions. Use the nested If for dependent conditions. And always pay attention to indentation so that dependencies are visible.
A select case and else if do not replace each other. A select case only evaluates a single expression and then checks the potential cases for that expression. An else if can check many expressions.

INI:
If Velocity > 100 Then
  do something if velocity > 100
elseif location = "South"
  do something if velocity <= 100 and in the South
elseif  Color <> "Red"
  do something if <= 100 and <> South and not Red
else
  do something if <= 100, not in South, Red
end if

The above cannot be written as a Select Case nor can it be written as multiple If Then.
Code:
if Velocity > 100 Then
  do something if velocity > 100
end if
if location = "South"
  do something if velocity <= 100 and in the South
end if
if  Color <> "Red"
  do something if <= 100 and <> South and not Red
end if
In the above event if the velocity is >100 it still will execute each subsequent check. You can do this with just If then else, but you would have to have much longer nested code. An else if is a shorter way of doing nested if thens not a select case alternative.
 
Last edited:
A select case and else if do not replace each other. A select case only evaluates a single expression and then checks the potential cases for that expression. An else if can check many expressions.

INI:
If Velocity > 100 Then
  do something if velocity > 100
elseif location = "South"
  do something if velocity <= 100 and in the South
elseif  Color <> "Red"
  do something if <= 100 and <> South and not Red
else
  do something if <= 100, not in South, Red
end if

The above cannot be written as a Select Case nor can it be written as multiple If Then.
Code:
if Velocity > 100 Then
  do something if velocity > 100
end if
if location = "South"
  do something if velocity <= 100 and in the South
end if
if  Color <> "Red"
  do something if <= 100 and <> South and not Red
end if
In the above event if the velocity is >100 it still will execute each subsequent check. You can do this with just If then else, but you would have to have much longer nested code. An else if is a shorter way of doing nested if thens not a select case alternative.

Agree with this, but why in any professional code, you would want to do that ?
Why is a location depending of the velocity ?
(I know it is an example)
If you have have different expressions to check, split them and make them easier to read. That is my opinion of course ;)
 
If you have to check 8 statments how would you start?
1. if
2. elseif
3.elseif
4.elseif
5. elseif
6.elseif
7.elseif
8.elseif
9. end if?
I dont know but this elseif is making me probelms when reading all my disaster...
Using Select Case ... End Select - 2 ways:

Code:
Private Sub NamenUporabe_Click()

  Dim criteria1 As String
  Dim criteria2 As String
  Dim criteria3 As String
  Dim criteria4 As String

  Select Case Me.NamenUporabe
    Case "TestnaAnaliza"
      Me.SproscanjeUstrezno = "N/A"
    Case Me.NamenUporabe = "SpreminjanjeStatusa"
      Me.SproscanjeUstrezno = "N/A"
      Me.OznakaInstrumenta = "N/A"
      Me.AnalitskiPostopek1 = "N/A"
      Me.AnalitskiPostopek2 = "N/A"
      Me.Analiza1 = "N/A"
      Me.Analiza2 = "N/A"
      Me.EmpChromChemMapa = "N/A"
      Me.RefNaAnalizo = "N/A"
      Me.StranStevilka = "N/A"
      Me.RaztopinaIzpiranje = "N/A"
      Me.CasIzpiranja = "N/A"
      Me.SteviloInjiciranj = "0"
      Me.AnalizaUstreza = "N/A"
    Case "RednaAnaliza"
      criteria1 = "[SproscanjeUstrezno] = 'DA' AND [KID] = " & Me.KID
      criteria2 = "[SproscanjeUstrezno] = 'DA' AND [KID] = " & Me.KID
      criteria3 = "[status] = 'approved' AND [KID] = " & Me.KID
      criteria4 = "[SproscanjeUstrezno] = 'DA' AND [KID] = " & Me.KID
      If DCount("*", "tblUporabaKolon", criteria1) = 0 Then
        MsgBox "Sproscanje ni bilo izvedeno.Prosim izvedite analizo sprošcanja.Ta zahteva ni mogoca in bo zavrnjena."
        Me.Undo
        DoCmd.Close acForm, "frmKoloneUporabaSUB"
      End If
    Case "Sprošcanje"
      If DCount("*", "tblUporabaKolon", criteria2) > 0 Then
        MsgBox "Ponovno želite izvajati analizo sprošcanja, ceprav je bilo Sprošcanje že ustrezno. Ta zahteva ni mogoca in bo zavrnjena."
        Me.Undo
        DoCmd.Close acForm, "frmKoloneUporabaSUB"
      End If
    End If
  End Select

End Sub

Private Sub NamenUporabe_BeforeUpdate(Cancel As Integer)

  Dim criteria3 As String
  Dim criteria4 As String

  Select Case True
  Case Me.StanjeSproscanja = "(3) Sproscena" And Me.NamenUporabe = "TestnaAnaliza"
    Me.StatusKolone = "(3) Sproscena"
    Me.SproscanjeUstrezno = "DA"
    Me.StatusKolone.Enabled = False
    Me.SproscanjeUstrezno.Enabled = False
  Case Me.StanjeSproscanja = "(3) Sproscena" And Me.NamenUporabe = "SpreminjanjeStatusa"
    Me.SproscanjeUstrezno = "DA"
    Me.OznakaInstrumenta = "N/A"
    Me.AnalitskiPostopek1 = "N/A"
    Me.AnalitskiPostopek2 = "N/A"
    Me.Analiza1 = "N/A"
    Me.Analiza2 = "N/A"
    Me.EmpChromChemMapa = "N/A"
    Me.RefNaAnalizo = "N/A"
    Me.StranStevilka = "N/A"
    Me.RaztopinaIzpiranje = "N/A"
    Me.CasIzpiranja = "N/A"
    Me.SteviloInjiciranj = "0"
    Me.AnalizaUstreza = "N/A"
  Case Me.StanjeSproscanja = "(3) Sproscena" And Me.NamenUporabe = "RednaAnaliza"
    criteria3 = "[status] = 'approved' AND [KID] = " & Me.KID
    criteria4 = "[SproscanjeUstrezno] = 'DA' AND [KID] = " & Me.KID
    If DCount("*", "tblKolone2", criteria3) > 0 And DCount("*", "tblUporabaKolon", criteria4) > 0 Then
      Me.StatusKolone = "(3) Sproscena"
      Me.SproscanjeUstrezno = "DA"
      Me.StatusKolone.Enabled = False
      Me.SproscanjeUstrezno.Enabled = False
      MsgBox "Analiza Sproščanja je bila izvedena vendar ni podpisana.Prosim podpišite analizo Sproščanja.Vaša zahteva bo zavrnjena."
      DoCmd.Close acForm, "frmKoloneUporabaSUB"
    End If
  End Select

End Sub
 
BeforeUpdate version can also be:
Code:
Private Sub NamenUporabe_BeforeUpdate(Cancel As Integer)

  Dim criteria3 As String
  Dim criteria4 As String

  If Me.StanjeSproscanja = "(3) Sproscena" Then
    Select Case Me.NamenUporabe
    Case "TestnaAnaliza"
      Me.StatusKolone = "(3) Sproscena"
      Me.SproscanjeUstrezno = "DA"
      Me.StatusKolone.Enabled = False
      Me.SproscanjeUstrezno.Enabled = False
    Case "SpreminjanjeStatusa"
      Me.SproscanjeUstrezno = "DA"
      Me.OznakaInstrumenta = "N/A"
      Me.AnalitskiPostopek1 = "N/A"
      Me.AnalitskiPostopek2 = "N/A"
      Me.Analiza1 = "N/A"
      Me.Analiza2 = "N/A"
      Me.EmpChromChemMapa = "N/A"
      Me.RefNaAnalizo = "N/A"
      Me.StranStevilka = "N/A"
      Me.RaztopinaIzpiranje = "N/A"
      Me.CasIzpiranja = "N/A"
      Me.SteviloInjiciranj = "0"
      Me.AnalizaUstreza = "N/A"
    Case "RednaAnaliza"
      criteria3 = "[status] = 'approved' AND [KID] = " & Me.KID
      criteria4 = "[SproscanjeUstrezno] = 'DA' AND [KID] = " & Me.KID
      If DCount("*", "tblKolone2", criteria3) > 0 And DCount("*", "tblUporabaKolon", criteria4) > 0 Then
        Me.StatusKolone = "(3) Sproscena"
        Me.SproscanjeUstrezno = "DA"
        Me.StatusKolone.Enabled = False
        Me.SproscanjeUstrezno.Enabled = False
        MsgBox "Analiza Sproščanja je bila izvedena vendar ni podpisana.Prosim podpišite analizo Sproščanja.Vaša zahteva bo zavrnjena."
        DoCmd.Close acForm, "frmKoloneUporabaSUB"
      End If
    End Select
  End If

End Sub
 
I don't use many elseif's if I can avoid it.
I use a case if I can see it's getting convoluted.

 

Users who are viewing this thread

Back
Top Bottom