Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    May 2008
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Making a subform visible (Access 2002)

    I have a subform inserted in a form whose standard state is not visible. I want it to become visible if I check a box. I have written the following event for the NewClient check box:
    Private Sub NewClient__AfterUpdate()
    Forms!subfrmClientTotas.Visible = Me.NewClient
    End Sub
    However, I get the error message: MStartUp can't find the form 'subfrmClientTotas' referred to in a macro expression or Visual Basic Code. I have checked the name of the sub form and it is correct.
    I would be grateful for any suggestions.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Making a subform visible (Access 2002)

    A subform is not part of the Forms collection, only main forms are.

    Try

    Me.subfrmClientTotas.Visible = Me.NewClient

    where subfrmClientTotas must be the name of the subform as a control on the main form.

  3. #3
    Lounger
    Join Date
    May 2008
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making a subform visible (Access 2002)

    that doesn't work because I get the error message 'method or data member not found'. It does not appear as an option after placing the dot after the M, nor does any variation of the name.
    I have checked yet again and have not misspelt the name of the subform. Could it be the fact that the form to which the subform is attached is itself a subform? (ie the visible/invisible one is the lowest in a nest of three).
    Regards
    Mary

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Making a subform visible (Access 2002)

    If the subform that you want to show/hide is a subform of a subform, you can use code like this:

    Me!FirstSubForm!subfrmClientTotas.Visible = Me.NewClient

    where FirstSubForm is the name of the subform as a control on the main form, and subfrmClientTotas is the name of the sub-subform as a control on the subform.

  5. #5
    Lounger
    Join Date
    May 2008
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making a subform visible (Access 2002)

    Dear Hans
    That did not work, but I fiddled around a bit and came up with a line that did which read:
    Me.Client_Totas.Visible=Me.NewClient
    I think I now realise that I am working under some misapprehension about naming because I then noticed that the subform seems to have two types of name arising from the fact that there also seems to be two distinct ways in which I can highlight the whole subform within its master form. Either
    a. with the top left black square showing, where there is no ‘Name’ heading just a ‘Caption’ heading with Client_Totas or;
    b. with the border highlighted but no black square, here there are two relevant headings:
    Name: Client_Totas
    Source Object: subfrmClientTotas

    This latter, source object name, is how I always thought I should refer to it in code, it is how it appears in the form window but judging from how I made the code work in the example above, I am obviously wrong, but why? Am I adrift between two totally different concepts?
    Sorry this is probably hopelessly elementary stuff, but not something I have every found explained anywhere.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Making a subform visible (Access 2002)

    subfrmClientTotas is the name of the subform as an object in the Database window, and Client_Totas is the name of the subform as a control on the main form.

    When you make a subform visible or invisible, you're not working with an object in the database window, but with a control on the main form. So you have to use the name of the subform as a control on the main form.
    The Source Object property specifies which object from the Database window is used to fill the subform control.

  7. #7
    Lounger
    Join Date
    May 2008
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making a subform visible (Access 2002)

    thank you so much, you have shed more light in five lines than five hours of reading manuals!
    Regards
    Mary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •