473,396 Members | 1,755 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,396 software developers and data experts.

Can I "lock" a record after saving to prevent future changes?

ollyb303
Hello,

I have created an access database to log complaint calls to my company. Sometimes these will result in a refund request being sent to our finance dept.

I have an event procedure which will send an email via lotus notes to the finance dept. when the Save button on the form is clicked.

I also have a Search (Find) button on the form so that users can look up previous complaints if necessary (which it sometimes is).

My problem is this:

If a user uses the search facility to find a record which has resulted in a refund request and clicks the Save button again, the refund request would be sent through to finance again (they shouldn't, but I'm trying to make this idiot-proof!).

Is there any way to prevent this from happening?

Many thanks,

Olly
Dec 7 '07 #1
6 3609
Jim Doherty
897 Expert 512MB
Hello,

I have created an access database to log complaint calls to my company. Sometimes these will result in a refund request being sent to our finance dept.

I have an event procedure which will send an email via lotus notes to the finance dept. when the Save button on the form is clicked.

I also have a Search (Find) button on the form so that users can look up previous complaints if necessary (which it sometimes is).

My problem is this:

If a user uses the search facility to find a record which has resulted in a refund request and clicks the Save button again, the refund request would be sent through to finance again (they shouldn't, but I'm trying to make this idiot-proof!).

Is there any way to prevent this from happening?

Many thanks,

Olly
It seems to me Olly that you simply need to add an additional piece of logic there and that is this:

If the 'status' of the record is flagged as 'refund email sent' either in a hidden field (if you think this is more appropriate for you) or a field 'visible' to the user and they understand the relevance of. Then a test could be applied to that value within the 'on click' event for the mail send.

I don't know what you have used there specifically for sending the mail via lotus notes but within that code if you are able to say that the email was 'actually sent' at the end of its program flow you could then simply update the status field of your table to 'email sent' and test against that value when the user clicks the 'Save' button something like this

Expand|Select|Wrap|Line Numbers
  1.  IF Me!Status="Refund Email Sent" Then 
  2. 'do nothing because an email has been sent for a refund
  3. ELSE
  4. 'the code that fires to send the mail and if sent sucessfully
  5. 'update the status field to read email sent and then save
  6. END IF
  7.  
I cannot see your program flow so obviously this is pure method guesswork and might even be more appropriate in the forms 'before update' event, it depends on what program flow you have there. It assumes of course you can add an extra field to your table to act merely as a status flag for the record.

Regards

Jim :)
Dec 7 '07 #2
Thanks Jim,

That makes perfect sense. I was thinking down completely different lines, but I think your idea will work just fine. Thanks for your help.

Olly
Dec 10 '07 #3
Thanks Jim,

This works just great. Problem is solved with 5 or 6 lines of code and I'm a happy man.

Olly :)
Dec 10 '07 #4
martin DH
114 100+
Thanks Jim,

This works just great. Problem is solved with 5 or 6 lines of code and I'm a happy man.

Olly :)
Good you post your final code? Thanks!
Dec 10 '07 #5
Expand|Select|Wrap|Line Numbers
  1. If RefundStatus = "sent" Then
  2.     MsgBox "THIS REFUND HAS ALREADY BEEN SENT - LOG NOT SAVED"
  3.     Exit Sub
  4. Else
  5.     End If
  6.  
  7. If Confirmation = -1 Then
  8.     strCC = "xxxx@xxxx.com" 
  9. Else:
  10.     strCC = ""
  11. End If
  12.     strTo = "xxxx@xxxx.com"     strSubject = "Refund"
  13.     strBody = "Refund for authorisation"
  14.     FirstFile = "h:\financereport.rtf"
  15.  
  16.     DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  17.  
  18.  
  19.  
  20.     If Refund_Amount > 0 Then
  21.  
  22.          If fIsAppRunning = False Then
  23.                 MsgBox "PLEASE LOG ON TO LOTUS NOTES BEFORE TRYING TO SEND REFUND REQUEST" & Chr$(10) & "                                              *REFUND NOT SENT*"
  24.                 Exit Sub
  25.         Else
  26.         End If
  27.  
  28.  
  29.         DoCmd.OutputTo acOutputReport, "FinanceReport", acFormatRTF, "H:\financereport.rtf"
  30.  
  31.         SendNotesMail strTo, strCC, strSubject, strBody, FirstFile
  32.         RefundStatus.SetFocus
  33.         RefundStatus.Text = "sent"
  34.         DoCmd.GoToRecord , , acNext
  35.         MsgBox "REFUND REQUEST HAS BEEN SENT TO FINANCE" & Chr$(10) & "              * LOG SAVED, THANK YOU *"
  36.  
  37.     Else
  38.         RefundStatus.SetFocus
  39.         RefundStatus.Text = "N/A"
  40.         DoCmd.GoToRecord , , acNext
  41.         MsgBox "* LOG SAVED, THANK YOU *"
  42.     End If
  43.  
Dec 10 '07 #6
N.B. I posted that at 5pm yesterday on my way out of work and didn't get chance to tidy up the indents etc. Sorry if it looks a bit messy, but it works!
Dec 11 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: titan nyquist | last post by:
I thought I need something like this, but it turns out I don't. I'm still interested if this can be done: Can you do a multi-thread "lock", that locks out everything else, all other threads,...
94
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
6
by: Curious | last post by:
I have an arraylist used in three separate methods. In method #1 (event method), some items are removed from the arraylist if certain conditions are met; In method #2 (event method),...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.