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