Is there a way to permanently change access form properties using VBA?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aflores41
    New Member
    • Nov 2014
    • 57

    Is there a way to permanently change access form properties using VBA?

    Tried the following code but it doesn't work. I was also hoping in adding this to the module so I can just call it in each forms using the me and not using form name.

    Code:
    Private Sub Form_Load()
    Me.RecordSelectors = False
    Me.NavigationButtons = False
    Me.ScrollBars = 0
    [Forms]![frm_Import].DefaultView = 5
    [Forms]![frm_Import].PopUp = True
    [Forms]![frm_Import].SplitFormOrientation = 1
    End Sub
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    If you placed this is a regular module, then you can't use the Me keyword and you can't call a Private sub from another module or class. What you should do is create a parameter so that the calling form can send its name and then you can edit the calling form's properties. ry the following:
    Code:
    Public Sub EditProperties(Frm As String)
    Forms(Frm).RecordSelectors = False
    Forms(Frm).NavigationButtons = False
    'Etc.
    End Sub
    To call this, all you have to do is enter the following in the form's OnLoad event:
    Code:
    EditProperties Me.Name
    Is there a reason you don't just set those properties in the properties window?

    Comment

    • aflores41
      New Member
      • Nov 2014
      • 57

      #3
      Thanks it works! I'm just being lazy at changing it one by one. I a lot of databases to build and this saves me time.

      The code below doesn't work though, could you assist?

      Code:
      Forms(frm).PopUp = True
      I get a run-time error 2136:
      to set this property, open the form or report in design view.

      Comment

      • Seth Schrock
        Recognized Expert Specialist
        • Dec 2010
        • 2965

        #4
        Per the MSDN website, the Popup property can only be set in form design view.

        Comment

        • Seth Schrock
          Recognized Expert Specialist
          • Dec 2010
          • 2965

          #5
          Another option is to create a form with the properties set how you want it and then same the form with the name of Normal. All new forms will be based on this template.

          Comment

          Working...