title: Intermittent run time error 3021 - No current record - MS Access
body: <p>TL;DR - Subs to do things with data in an access data entry form in other MS applications will <em>sometimes</em> throw a 3021 error for <em>some</em> users but following the exact same steps again doesn't cause an error.</p>
  
  <p>This error is driving me bonkers. I have been searching through questions here and in every other forum I can find and either they don't apply to my situation or they're not giving me enough information to figure out what's going on so I know which step to take next.</p>
  
  <p>I have a split database with BE stored in Sharepoint Lists. FE is just the app on each users local machine. There are quite a few forms and reports and queries, but the general idea is that this is used to log issues between two different departments with a myriad of other information in different formats. There are 3 main forms that are used: the issue entry form, and then 2 forms for each department to update their side's information.</p>
  
  <p>On the main issue entry form there are a few command buttons and the close button is disabled. A couple of these buttons are "Save and new", "Save and Exit", "Delete and Exit". These work as expected and there's no issues there. The other buttons all either open up an Outlook task or open up an Excel file and fill those items with data from the form. All of the subs for the command buttons look similar to the below:</p>
  
  <pre><code>If Me.Dirty Then Me.Dirty = False
  Set OApp = CreateObject("Outlook.Application")
  Set OTask = "OApp.CreateItem(3)
  
  'Start taking pieces of the form and assigning it to the task
  </code></pre>
  
  <p>The comment above is where all of these subs misbehave. But the problem and the reason I'm going crazy is because it doesn't happen all the time. Every time this happens (so far about 10 times out of 400 entries) one of my users comes and gets me and I look and the entire form is cleared out like they haven't typed anything so I understand the 3021 error, but the record was saved so it has to at least be reaching the Me.Dirty part of my code. I just don't understand why it's clearing out the form and raising an error when I start trying to do something outside of Access.</p>
  
  <p>With this being intermittent, I don't even know what my next step is to try and find this random bug that chooses to happen or not based on which way the wind is blowing.</p>
  
  <p><strong>Edit 1:</strong> So I've dug in and figured out when this is happening and where in the code it's happening. So this only happens the first time the user opens a form for data entry after downloading the latest version. If they close it all down and reopen it, there's no more issues. The reason it seemed so intermittent is because some users would download it Monday. Some would download it Thursday. Some would download it the next week. They just download it the next time they have to use the database. The 3021 "No current record" is actually happening on the Me.Dirty = False line. The If Me.Dirty line is what's actually clearing the form. Since the record was being saved I assumed it was making it past that point, but it's not. The odd thing is that if I use a breakpoint to step through the code I get a 3167 "Record is deleted" error when I get to that line instead of 3021. And the oddest thing about all of this is that it quits happening if the user just closes it all and reopens after a fresh download.</p>
  
  <p>Summary:</p>
  
  <pre><code>If Me.Dirty Then '&lt;--This clears the form
  Me.Dirty = False '&lt;--This results in error 3021 because the form is now empty
  </code></pre>