title: MS Access: Object Required error
body: <p>This code is just meant to figure out a total and then a percentage of that total, and then display the percentage amount in a textbox. This code runs when a button on a form is clicked, but it uses data based in a subform on that form, and the textbox that it should display to is on the form. Both the form and the subform are invoked in the class list, so it confuses me as to why it comes up with an "Object Required" error.</p>
  
  <pre><code>Private Sub cmdTest_Click()
  'Initialisation
  Dim TotalAmount As Integer 
  Dim GiftAid As Integer
  'Processing
     If AllForms!frmGiftAid!subfrmqryGiftAid!PaymentIncrement Is Not Null Then
         If AllForms!frmGiftAid!subfrmqryGiftAid!PaymentIncrement = "Monthly" Then
            TotalAmount = _
              (AllForms!frmGiftAid!subfrmqryGiftAid!PaymentAmountPerIncrement * 12)
         Else
            TotalAmount = _
              AllForms!frmGiftAid!subfrmqryGiftAid!PaymentAmountPerIncrement
         End If
     End If
  
     'Termination
     GiftAid = (TotalAmount * 0.25)
     AllForms!frmGiftAid!subfrmqryGiftAid!subfrmqryGiftAidtxtGiftAid = GiftAid
  End Sub
  </code></pre>
  
  <p>The line that the error occurs on is the first one that references the subform, so it's:</p>
  
  <p>If AllForms!frmGiftAid!subfrmqryGiftAid!PaymentIncrement Is Not Null Then</p>
  
  <p>I've tried using different variations of the code to reference the subform (just referencing the subform, using "Forms" instead of "AllForms") as well as trying it in the subform itself rather than the form and doing so on different events, such as On_Current() or On_Load(), but nothing has worked for me so far.</p>
  
  <p>Any help that you could offer me would be greatly appreciated.</p>