Results 1 to 5 of 5
  1. #1
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328

    Disable subform using a module

    I am trying to do unclutter by using modules more than I have in the past. I am trying to do something that I thought was simple. I would like to set a subform enable property to false. If I do it in vba in the parent with:
    Me.F_Main_adderDB_SUB.Enabled = False
    It works fine

    If I try to use a module, I put
    Call TEST1("F_Main_adderDB_SUB") in the main form.

    In the module, I put
    Screen.ActiveForm.SFN.Enabled = False and get an error message.
    What am I missing? Googled, but found all help was for part I already can do. Any help much appreciated.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You will have to pass the name of the Main Form and subform control to your function. Might as well not have a custom user defined function for this since you have access to the Me shortcut from the main form's module.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Custom Functions have their place, for groups of actions that are needed in various places within your code, but what would be the point in replacing one line of code, to do a task, with one line of code to call a function to execute one line of code?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    There is a lot more code in the module involving these same forms. I just showed the one item for clarity What is the format for doing this (subform enable=false) with a module?. Is there some book or site that discusses the differences we run into when coding with a module?

    I am attaching this same message to the other reply as I assume this goes only to the responder.

  5. #5
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    In case someone is looking for an answer, I experimented and found this works

    Public Sub En(SFN)
    Screen.ActiveForm.Form(SFN).Enabled = True 'Forgot need "Form".
    End Sub

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

Similar Threads

  1. How to disable subform row single field
    By tahirsatti in forum Forms
    Replies: 3
    Last Post: 05-09-2013, 12:07 AM
  2. If IsNull CustomerID Then Disable Subform
    By burrina in forum Forms
    Replies: 7
    Last Post: 12-11-2012, 06:45 PM
  3. disable controls on a subform,
    By jaymin in forum Database Design
    Replies: 2
    Last Post: 06-23-2012, 07:05 AM
  4. Disable new entry in subform
    By mdewell in forum Forms
    Replies: 3
    Last Post: 01-05-2012, 02:38 PM
  5. Replies: 1
    Last Post: 08-06-2010, 07:50 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