Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8295179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:29:31+00:00 2026-06-08T14:29:31+00:00

I have a Sub within my application that is currently located within a userform

  • 0

I have a Sub within my application that is currently located within a userform called FRMPFC_folderCreatorWindow. For clarity of the overall application I wish to move this Sub from the userform into a Module called PFC_filesystemManipulation and call the Sub from there via a button in FRMPFC_folderCreatorWindow however, when I do this and run my code, an error is generated at the line:

For Each cCont In Me.Controls

I understand that this is because the Sub has been taken outside of the context of the form however, how do I maintain context without using Me.Controls? I’m guessing I need to reference the form and use FRMPFC_folderCreatorWindow.Controls but as most of the controls are nested within frames I’m unsure whether my current code acts upon the form or just the frame within which the button is located. Any help would be much appreciated.

Private Sub PFC_createFolders(Basepath, currentControl, parentFolder, parentGroup)

Dim cCont As Control
Dim createSubFolder As String
Dim fs As Object

Set fs = CreateObject("Scripting.FileSystemObject")

'Check if the project folder already exists and if so, raise an error and exit
    MkDir Basepath & "\" & parentFolder

    'Create the superceded documents folder in every 2nd generation folder
    MkDir Basepath & "\" & parentFolder & "\" & "_Old versions"
    For Each cCont In Me.Controls
        If TypeName(cCont) = "CheckBox" Then
            If cCont.GroupName = parentGroup Then
                If cCont.Value = True Then
                    If cCont.Name <> currentControl Then
                        createSubFolder = cCont.Caption
                        NewFolder = Basepath & "\" & parentFolder & "\" & createSubFolder
                        If fs.folderexists(NewFolder) Then
                            'do nothing
                        Else
                            'Create 3rd generation folder
                            MkDir NewFolder

                            'Create the superceded documents folder in every 3rd generation folder
                            MkDir NewFolder & "\" & "_Old versions"

                            'Create hard-coded subfolders within Confirmit Exports
                            If createSubFolder = "Confirmit Exports" Then
                                MkDir Basepath & "\" & parentFolder & "\" & createSubFolder & "\Triple S"
                                MkDir Basepath & "\" & parentFolder & "\" & createSubFolder & "\Word Export"
                                MkDir Basepath & "\" & parentFolder & "\" & createSubFolder & "\Survey Definition"
                                MkDir Basepath & "\" & parentFolder & "\" & createSubFolder & "\Data"
                                MkDir Basepath & "\" & parentFolder & "\" & createSubFolder & "\Data" & "\" & "Early Data"
                                MkDir Basepath & "\" & parentFolder & "\" & createSubFolder & "\Data" & "\" & "Final Data"
                            End If

                        End If

                    End If

                End If

            End If

        End If

    Next cCont

   End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:29:33+00:00Added an answer on June 8, 2026 at 2:29 pm

    I’ve just experimented with this and replacing the Me.Controls with the following code works:

        FRMPFC_folderCreatorWindow.Controls
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a web application project that also includes web services within the
I have identified a problem within my application; basically, one sub-routine prepares (lots) of
I have an ASP.Net 4.0 application, and within it is a folder called Forum,
Inside of my MVC application, I have a sub-folder named Admin that was Converted
This is the code I have: Sub Main() Dim dts As New DataSet Dim
We have a sub-project 'commonUtils' that has many generic code-snippets used across the parent
I have a sub query that returns one column, showing as GroupType, I then
I have a sub form in Access: The CopyNo is a combobox that lets
I have a sub form that looks like a datasheet view. It returns prices
In a module i have a sub that create modalpopup and show result of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.