title: Event not Firing in MS Access VBA
body: <p>I have a form in MS Access which has an image.  The image has an Click event which opens a modal form.  The modal form has an OK and Cancel button.  When you click the OK button, an event is supposed to fire which tells the main form which button was clicked.  (This is to simulate the DialogResult functionality in C#).  However, the code in the event handler never runs.</p>
  
  <p>The modal form has the following in the general declarations:</p>
  
  <pre><code>Public Event OnDialogBoxClose(NewRecordID As Long, DialogResult As DialogResults)
  </code></pre>
  
  <p>and the following code where the OK button is clicked:</p>
  
  <pre><code>RaiseEvent OnDialogBoxClose(NewHardwareBaseItemID, dlgresBtnOKClicked)
  </code></pre>
  
  <p>The main form has the following in the general declarations:</p>
  
  <pre><code>Dim WithEvents RespondQuickAddClose As Form_qckfrmHardwareBaseItemCreate
  </code></pre>
  
  <p>and the following event handler:</p>
  
  <pre><code>Private Sub RespondQuickAddClose_OnDialogBoxClose(NewRecordID As Long, DialogResult As DialogResults)
  
      MsgBox "Responding to closing of the dialog box" 'Never happens
      Me.Requery
  
  End Sub
  </code></pre>
  
  <p>Can someone explain why the event handler is never called?
  Thanks!</p>
  
  <p>Background:</p>
  
  <p>The purpose of all this is to allow a modal dialog box to add an entry, then return the ID of the entry back to the main form to set the value of controls.  For instance, imagine you are filling out an insurance form, and you need to select a brand of car this is not there.  You click on an icon which pops up with the modal dialog box to allow you to add the car brand.  Then when you click OK, it takes you back to the insurance form and selects the brand of car you just created.</p>
  
  <p>This follows an example I found here:
  <a href="http://database.itags.org/ms-access-database/80292/" rel="nofollow noreferrer">http://database.itags.org/ms-access-database/80292/</a></p>