Hello,
Recently I found a bug in my database, and I cannot seem to figure the solution out, so I would like ask for your help in this matter.
So in my database I have a form with a subform. When I click the save button I want the program to ask me if I want to save the changes I made, and in case I click NO, I want the records to remain the same. It worked really well until I noticed, that if I modify a record in the Main form and after that I do something in the subform, then if I click save, the program won’t ask for confirmation. Also “tied” to the save button I also have a sort of “validation rule” where I check if certain fields changed value, because in case I save the changes the program should make alterations to another field in light of the changes made in the record.
Now it would be really important that the program asks for confirmation, do you have any idea how can I resolve this problem?
Here is my existing code:
Private Sub saveBtn_Click()
'Validation rule
If Me.Izolálás_eredménye = "sikeres" And Nz(Me.Törzs_név, "") <> "" Then
If Nz(Me.Szubtípus.OldValue) <> Nz(Me.Szubtípus) Then
If MsgBox("A szubtipus modsitasaval modositani kell a törzsnevet is. Mented a szubtipus modosítását?", vbYesNo) = vbYes Then
Me.Törzs_név = Me.Előzetes_eredmény & "/Hungary/" & Me.Sorszám & "/" & Me.Izolálás_éve & "(" & Me.Szubtípus & ")"
Else
Me.Szubtípus = Me.Szubtípus.OldValue
End If
End If
End If
Dim MBszam As String
MBszam = Me!MBszám
'modositott rekord mentese
If Me.Dirty = True Then
If MsgBox(" Mented a változtatásokat?", vbYesNo) = vbYes Then
Me.Dirty = False 'with this we force access to save changes
Else
Me.Undo
End If
End If
DoCmd.Close acForm, "frm Main Edit"
DoCmd.OpenForm "frm Main Open", OpenArgs:=MBszam
End Sub
Thanks in advance,
Regina
Recently I found a bug in my database, and I cannot seem to figure the solution out, so I would like ask for your help in this matter.
So in my database I have a form with a subform. When I click the save button I want the program to ask me if I want to save the changes I made, and in case I click NO, I want the records to remain the same. It worked really well until I noticed, that if I modify a record in the Main form and after that I do something in the subform, then if I click save, the program won’t ask for confirmation. Also “tied” to the save button I also have a sort of “validation rule” where I check if certain fields changed value, because in case I save the changes the program should make alterations to another field in light of the changes made in the record.
Now it would be really important that the program asks for confirmation, do you have any idea how can I resolve this problem?
Here is my existing code:
Private Sub saveBtn_Click()
'Validation rule
If Me.Izolálás_eredménye = "sikeres" And Nz(Me.Törzs_név, "") <> "" Then
If Nz(Me.Szubtípus.OldValue) <> Nz(Me.Szubtípus) Then
If MsgBox("A szubtipus modsitasaval modositani kell a törzsnevet is. Mented a szubtipus modosítását?", vbYesNo) = vbYes Then
Me.Törzs_név = Me.Előzetes_eredmény & "/Hungary/" & Me.Sorszám & "/" & Me.Izolálás_éve & "(" & Me.Szubtípus & ")"
Else
Me.Szubtípus = Me.Szubtípus.OldValue
End If
End If
End If
Dim MBszam As String
MBszam = Me!MBszám
'modositott rekord mentese
If Me.Dirty = True Then
If MsgBox(" Mented a változtatásokat?", vbYesNo) = vbYes Then
Me.Dirty = False 'with this we force access to save changes
Else
Me.Undo
End If
End If
DoCmd.Close acForm, "frm Main Edit"
DoCmd.OpenForm "frm Main Open", OpenArgs:=MBszam
End Sub
Thanks in advance,
Regina