By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,656 Members | 920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,656 IT Pros & Developers. It's quick & easy.

Re: oldvalue, combo box, beforeupdate

P: n/a
Testing if the new value is different from the old one avoids giving the
message in these cases:
a) It's a new record (so there was no old value.)
b) No customer was specified previously (so the customer wasn't 'changed'.)
c) No customer is specified now. (You may or may not want to check this.)
d) The record was edited, but the customer wasn't changed (including leaving
it blank as it was before.)

Most of these have to do with handling Nulls. If you want to read further
about considering the 3 possible outcomes for any comparision (True, False,
or Null), see the last error addressed in this article:
Common Errors with Null
at:
http://allenbrowne.com/casu-12.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"franc sutherland" <fr**************@googlemail.comwrote in message
news:ce**********************************@p35g2000 prm.googlegroups.com...
On Nov 15, 2:31 am, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
>
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
Dim bWarn As Boolean

With Me.Customer_id
If .Value <.OldValue Then
bWarn = True
strMsg = strMsg & "Changed customer from " & .OldValue & " to "
& .Value." & vbCrLf
End If
End With

If bWarn And Not Cancel Then
If MsgBox(strMsg, vbOkCancel+vbQuestion, "Confirm change") <vbOk
Then
Cancel = True
Me.Undo
End If
End If
End Sub
Thanks for that. It worked a treat. However, I don't understand why
the code I was using wasn't given the same outcome. Reading it
through, it seems to follow the same logical path. Is the new value
the same as the old value, if not, confirm action and then update or
undo. Can you explain, please?

Nov 19 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Nov 19, 1:35*pm, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
Testing if the new value is different from the old one avoids giving the
message in these cases:
a) It's a new record (so there was no old value.)
b) No customer was specified previously (so the customer wasn't 'changed'..)
c) No customer is specified now. (You may or may not want to check this.)
d) The record was edited, but the customer wasn't changed (including leaving
it blank as it was before.)

Most of these have to do with handling Nulls. If you want to read further
about considering the 3 possible outcomes for any comparision (True, False,
or Null), see the last error addressed in this article:
* * Common Errors with Null
at:
* *http://allenbrowne.com/casu-12.html

--
Allen Browne - Microsoft MVP. *Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"franc sutherland" <franc.sutherl...@googlemail.comwrote in message

news:ce**********************************@p35g2000 prm.googlegroups.com...
On Nov 15, 2:31 am, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:


Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
Dim bWarn As Boolean
With Me.Customer_id
If .Value <.OldValue Then
bWarn = True
strMsg = strMsg & "Changed customer from " & .OldValue & " to "
& .Value." & vbCrLf
End If
End With
If bWarn And Not Cancel Then
If MsgBox(strMsg, vbOkCancel+vbQuestion, "Confirm change") <vbOk
Then
Cancel = True
Me.Undo
End If
End If
End Sub

Thanks for that. *It worked a treat. *However, I don't understand why
the code I was using wasn't given the same outcome. *Reading it
through, it seems to follow the same logical path. *Is the new value
the same as the old value, if not, confirm action and then update or
undo. *Can you explain, please?
Thanks Allen.

Much appreciated,

Franc.
Nov 19 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.