title: How to test if current record has changed when command button clicked on continuous form
body: <p>In ms access, I have a mainform with 2 subforms. SubformA is a continuous form with record title and a transparent button overlay for each record. SubformB contains the detail of the selected record (this is on tabcontrol elsewhere within the mainform, mimicking a popup overlay).</p>
  
  <p>What I want to happen is:<br>
   1. Clicking a record subformA displays subformB and filters it to that record.<br>
   2. Moving through records on subformA updates so that subformB always displays the corresponding record.<br>
   3. Clicking a record on subformA hides subformB again ONLY IF it is the record that is currently being displayed.</p>
  
  <p>However I cannot work out how I can test for if the current record is the one that was clicked because as soon as I click the button, if it is not the current record, the current event fires first, making it the current record, and hence always hiding subformB.</p>
  
  <p>I tried using a variable to check at the start and end of the current event if the id on subformB stays the same. However, the current event of course does not trigger in the situations where the record has not changed, which is when I need to test this variable.</p>
  
  <p>Stripped down/pseudocode in subformA for what I have tried to do:</p>
  
  <pre><code>Sub Form_Current
    If subformB.Visible Then set filter on subformB to ID = subfromA.ID
  End Sub
  
  Sub cmdButton_Click
    If subformB.Visible Then
      If subformB.ID = subformA.ID Then 
        Hide subformB
      Else
        'code never gets to here because the condition is always true 
        'do nothing - current event has already set the filter
      End If
    Else
      Unhide subformB
      Set filter to ID = subformA.ID
    End If
  End Sub
  </code></pre>
  
  <p>Is anybody able to help me here? Thanks.</p>
  
  <p>EDIT: what I am asking is how can I test the current record ID against the record ID of the record where the command button was clicked - but the record ID when clicking the button is of course just taking the new current record ID. Therefore it is comparing old current record ID to new current record ID, the problem being how do I store the old ID but prevent it from being updated again before the condition is tested.</p>