Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8355133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:46:27+00:00 2026-06-09T09:46:27+00:00

This code is just meant to figure out a total and then a percentage

  • 0

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.

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

The line that the error occurs on is the first one that references the subform, so it’s:

If AllForms!frmGiftAid!subfrmqryGiftAid!PaymentIncrement Is Not Null Then

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.

Any help that you could offer me would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:46:28+00:00Added an answer on June 9, 2026 at 9:46 am

    Reference the subform starting either with Me from the code module of the form, or Form, followed by the name of the form. You then have the name of the subform control, Form, to refer to the object contained, and finally and property of the contained form.

     Forms!frmGiftAid!subfrmqryGiftAid.Form!PaymentIncrement
    

    Or

     Me.subfrmqryGiftAid.Form.PaymentIncrement
    

    Note that it is important to use the name of the subform control, not the name of the form contained.

    This code would run on the parent form and a record would need to be selected on the subform.

    If Not IsNull(Me.subfrmqryGiftAid.Form.PaymentIncrement) Then
       If Me.subfrmqryGiftAid.Form.PaymentIncrement = "Monthly" Then
          TotalAmount = _
            Me.subfrmqryGiftAid.Form.PaymentAmountPerIncrement * 12)
       Else
          TotalAmount = _
            Me.subfrmqryGiftAid.Form.PaymentAmountPerIncrement
       End If
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this test code that just saves an XML file to a folder.
I'm trying to figure out some C code so that I can port it
Can anybody help with this code I just don't know where I am going
I am working on const-correctness of my code and just wondered why this code
this code in my plugin used to work just fine: jQuery('#embedded_obj', context).get(0).getVersion(); and the
Given this JavaScript code (which is just a comment referring to a url): //
I just saw this code while studying the wordpress source code (PHP), You can
I just found this code in reflector in the .NET base libraries... if (this._PasswordStrengthRegularExpression
This code works on one of my dev boxes (using JQ v1.3.2.) I just
is it just me or this code in Programming Pearls is wrong (quicksort wants

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.