473,324 Members | 2,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Re: oldvalue, combo box, beforeupdate

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
1 7328
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul | last post by:
I have read the posts on using Sendkeys to dropdown the list in a combo box. However, doesn't that require the combo box to have the focus? My situation is a little different. I have a text...
2
by: Bob Darlington | last post by:
When a user clears a value from a combo box (by pressing the delete key), the following message appears: "You tried to assign the null value to a variable that is not a variant data type". ...
0
by: Bob Darlington | last post by:
I'm using the following code, which is called from the BeforeUpdate event in a form based on 'Tenant Details', to check for changes or additions to a series of dates, and if changed, to edit...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
9
by: Vmusic | last post by:
Hi, I'm using MS Access 2002. I have a form with a combo box built from a query that returns one column, and that one column is the bound column. How do you use VBA to programmatically change...
1
by: gazelle04 | last post by:
I have these on BeforeUpdate event of a control If Me.txtAddress.Value <> Me.txtAddress.OldValue Then Me.txtGenInfo_UpdatedOn = Now Me.txtGenInfo_UpdatedBy = fOSUserName ...
8
by: Michael R | last post by:
Dear users and experts, An unbound combo box in my form is responsible for changing a city name for an update query that creates a temprorary table which the form uses as its record source. In...
9
by: prakashwadhwani | last post by:
I have an unbound combo box in the form header. I have used an input mask "CCCC" 40 times to limit the max number of characters to 40. When I tab into the combo box & press a character say "K"...
7
by: phill86 | last post by:
Hi, I have a form with a number of combo box's the first combo box contains a barcode that is associated with user information then the next box contains a barcode that is associated with task...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.