
  Disclaimer: I don't know much about DAO. I typically use ADODB.


The expensive part of this code is opening and closing the recordset repeatedly. So, instead of opening and closing it every time this is triggered, open it once when the form is first loaded.

Private dbTemp As DAO.Something 'I don't know the right type
Private rsTemp As DAO.Recordset
Private rsTemp2 As DAO.Recordset

Private Sub Form_Load()
    ' code to open the entire recordset without a filter
End Sub

Private Sub Form_Unload()
    ' code to close and dispose of the recordsets
End Sub


Of course, now you don't have the specific record you're looking for when the event fires. You can use the Find and FindNext methods to filter the entire recordset down to what you need in the event procedure.

https://msdn.microsoft.com/EN-US/library/office/ff194787.aspx



Of course, this is if I can't talk you into switching to ADODB for your purposes here. It supports parameterized queries, which (in theory) should execute a bit faster. This is because, to the best of my knowledge, DAO requests all of the data and then filters it down in memory on the local machine. An ADODB parameterized query allows for the plan to be cached and only returns the results of the statement.

Dim rst As ADODB.Recordset
Dim cmd as ADODB.Command

Const sql as String = _
    "SELECT Field1 " &amp; _
    "FROM Table " &amp; _
    "WHERE CustomerID = ? and MonthYear = ?"

With cmd 
     .CommandType = adCmdText
     .CommandText = sql

     .Parameters.Append .CreateParameter(...)
     .Parameters.Append .CreateParameter(...)

     Set rst = .Execute
End With

' some code to set january's value

cmd.Parameters(1).Value = feburaryDate

Set rst = cmd.Execute

' some code to set february's value


Note how we simply pass the query a new value, instead of duplicating all of the query text? This is just one of ADODB's benefits.



One other, rather minor note.

I bet this code is all through your code base.


 MsgBox "Error " &amp; Err.Number &amp; ": " &amp; Err.Description &amp; " in " &amp; _
   VBE.ActiveCodePane.CodeModule, vbOKOnly, "Error"



It's well worth extracting the logic into a dedicated module or class to standardize your error handling UI.

DAO recordset effiency
We currently have our code managed such that each site has its own theme and install profile. 
These have naturally evolved in such a way that the names of these items (and their directories) tend to be the same. 

For example, one site's theme and profile are both called 'dennis'

This causes problems with feature servers, and (I'm suspecting) with Aegir.

Now... it's relatively easy to rename either of these (although, for various reasons it's noticeably easier to rename the profile). Is there any sort of best practice here, ie is it normal to call the theme dennis_theme, or the profile dennis_profile? Should I apply this convention to both, or just to one?
