Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2004
    Location
    NY
    Posts
    113

    Unanswered: subform in many forms

    Hi,
    I have a subform that I want to use in many forms. However, I don't want the same exact text fields to be displayed in some forms. Am I better off creating a copy of this subform and deleting these fields and inserting them into the specific forms. Or is it possible to code:
    if subform is in this form then
    do not display

  2. #2
    Join Date
    Sep 2004
    Location
    Dallas, TX
    Posts
    77
    list all field in the subform.
    set the one doesn't use in every form as invisble.

    when do u need use it, change it to visible

  3. #3
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    I would try to reuse the same subform for all of the forms. Unless it gets too complicated or space on a form is limited and you need the space that would be wasted by the control(s) that are invisible.

    You can go at it a couple of ways. You can put the code in the subform and check to see what form you are in using Me.Parent.Name. Or you can put the code in each form that needs to hide some of the controls. To get to the controls use Me.subformname.Form.Controls(ControlName).Visible. I would put the code in the Open Event of the form.

  4. #4
    Join Date
    Aug 2004
    Location
    NY
    Posts
    113
    Thanks for the quick response.

    I entered this into the Main from in the open event

    Me.sfrmInvoice.Form.Controls(txtcode).Visible

    but I get an error:

    Object doesn't support this property or method (Error 438)

    I did make the txtcode invisible in the subform by default.

  5. #5
    Join Date
    Jan 2003
    Posts
    81
    To hide:

    Me.sfrmInvoice.Form.Controls(txtcode).Visible = False

    To show:

    Me.sfrmInvoice.Form.Controls(txtcode).Visible = True

    Bjorn

  6. #6
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Don't forget the double quotes:

    Me.sfrmInvoice.Form.Controls("txtcode").Visible

  7. #7
    Join Date
    Aug 2004
    Location
    NY
    Posts
    113
    Bjorn, DCKunkle

    Thanks for your help. Me.sfrmInvoice.Form.Controls("txtcode").Visible does work but only in single view form. Is there a way to prevent a control in datasheet form from showing?

    thanks

Posting Permissions

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