Results 1 to 5 of 5
  1. #1
    Johnain is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Location
    Aquitaine, France
    Posts
    12

    Unable to reference a subform by name after renaming it


    Hi all
    I have a Sales Order form named SlsOrders and its SubForm now named SlsOrdRows.

    I renamed the subform because I originally gave it a long complicated name with a space in it. Since renaming it I have checked out the the Subform container record in the main form and altered these properties...

    Source Object To a value of SlsOrdRows
    Name To a value of SlsOrdRows

    In the Main form (SlsOrders) I have a control called AmountTotal.

    In the SubForm I have a column called Amount which I want to sum the Amounts in all of the SlsOrdRows.

    To do this I have set up a Contol in the footer of the SubForm SlsOrdRows called TotalAmount with a Control Source of =Sum(Amount).

    The AmountTotal in the SlsOrders form is bound by Control Source to the field Amount in my Sales Order Header Table total so I cannot reference it to the TotalAmount Control in the footer of the SubForm.

    So I tried .....

    Forms!SlsOrders.TotalAmount.Value = Forms!SlsOrders!SlsOrdRows.AmountTotal.Value

    The error message that I get is "Run Time Error: Object doesn't support this property or method.

    I know that the problem does not relate to the Forms!SlsOrders.TotalAmount.Value bit because I tried

    Forms!SlsOrders.TotalAmount.Value = 2 and that worked fine. So the issue seems to be in the renamed SubForm.

    So I am stuck on this frustrating problem. Is there some other identifier that I must change after the rename, or perhaps another issue?

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Try
    Code:
    =[SlsOrdRows].[Form]![AmountTotal]
    as control source

  3. #3
    Johnain is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Location
    Aquitaine, France
    Posts
    12
    Hi Amrut

    Thanks for the response. Unfortunately I cannot do that for a design reason. The Control source in my AmountTotal object is already in use because it is bound to the table field in my SlsOrder table.

    I have, however cheated a little in my code. Now I say ...

    Forms!SlsOrders.TotalAmount.Value = Me!AmountTotal.Value


    ... and that works fine. Which makes me think that it's the subform name it doesn't recognise. But that avoids the issue rather than resolving it. Because I cannot refer to the subform in my VBA other than in Subform level code where I can use My!

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    You don't reference a subform by its name - you need to use the name of the container its in, plus the property .form:

    Forms!SlsOrders.TotalAmount.Value = Forms!SlsOrders!SubformContainerName.form!TotalAmount.Value

    Replace SubformContainerName with the actual name of your subform container control.

    HTH

    John

  5. #5
    Johnain is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Location
    Aquitaine, France
    Posts
    12
    Hi

    Thanks again. Actually, that is what I have done. It is a real puzzle to me.

    However it may well be linked to the fact that I am a novice :-)

    John

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Unable to create duplicate record on subform
    By nika.duncan in forum Programming
    Replies: 9
    Last Post: 12-02-2013, 02:26 PM
  2. Replies: 3
    Last Post: 11-05-2012, 03:50 PM
  3. Replies: 11
    Last Post: 09-17-2012, 02:23 PM
  4. Replies: 5
    Last Post: 08-09-2012, 12:49 PM
  5. Can't reference control in subform
    By evanscamman in forum Forms
    Replies: 0
    Last Post: 12-25-2007, 06:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums