hugomadail
Registered User.
- Local time
- Today, 04:17
- Joined
- Aug 31, 2018
- Messages
- 25
Hello, I have a form with two cascading comboboxes - cbA e cbB, where cbB is filtered with cbA choice (all works well here).
BUT the problem is because I'm trying to make a messagebox to warn when cbA is changed, so I used cbA before update event to make a tempvar about old record in cbA, then a cbA after update event to check if new record is the same as tempvar or not, also checks if cbB has record or is null. the code I'm using:
So "Private Sub cbA_AfterUpdate()" should be checking if new cbA value is different than FrOld (old cbA value) and also cbB cannot be null! I think problem is with "If [cbA].Value <> TempVars("FrOld") Then" part because if I use a number (ex: 19) instead of tempvar, the code works. the tempvar seems to be well defined because I placed a independent checkbox on form to display tempvar value and it shows the value!
I'm not a programmer so I did this code by trial and error, but now I don't know what I'm doing wrong.
Can someone help me with a solution?
BUT the problem is because I'm trying to make a messagebox to warn when cbA is changed, so I used cbA before update event to make a tempvar about old record in cbA, then a cbA after update event to check if new record is the same as tempvar or not, also checks if cbB has record or is null. the code I'm using:
Code:
Private Sub cbA_BeforeUpdate(Cancel As Integer)
TempVars!FrOld = Me.cbA.Value
End Sub
Private Sub cbA_AfterUpdate()
If [cbA].Value <> TempVars("FrOld") Then
If Not IsNull(cbB) Then
If MsgBox("you chose to change cbA value to another and theres already a record on cbB, do you validate changes and clear cbB?", vbYesNo + vbQuestion, "Warning") = vbYes Then
[cbB].Value = Null
End If
End If
End If
End Sub
So "Private Sub cbA_AfterUpdate()" should be checking if new cbA value is different than FrOld (old cbA value) and also cbB cannot be null! I think problem is with "If [cbA].Value <> TempVars("FrOld") Then" part because if I use a number (ex: 19) instead of tempvar, the code works. the tempvar seems to be well defined because I placed a independent checkbox on form to display tempvar value and it shows the value!
I'm not a programmer so I did this code by trial and error, but now I don't know what I'm doing wrong.
Can someone help me with a solution?
Last edited by a moderator: