Results 1 to 7 of 7
  1. #1
    DMT Dave is online now VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195

    Populating Inputbox

    Hi All, the following code will add folder names to a Combo Box, is it an easy task to populate to an input box instead and have a unique number to follow the path to the selected folder in a dialog box using Dim fd as FileDialog ?



    Code:
    Set fso = CreateObject("Scripting.FileSystemObject")    Me.cboViewPO.RowSource = ""
        Me.cboViewPO.Requery
        SubFolderName = "T:\Folder1\Folder2\"
        Set flD = fso.getfolder(SubFolderName)
        For Each Fil In flD.Files
            i = i + 1
        Me.cboViewPO.AddItem Fil.Name ' ADD TO INPUTBOX ?? 
        Next Fil
        Me.lblPOs.Caption = i & " " & "PDF's"
        Me.cboViewPO.Requery
    ABOVE WORKS GREAT TO POPULATE A COMBO WITH FOLDER NAMES
    BELOW IS SOMETHING I AM LOOKING TO DO IS POPULATE AN INPUTBOX MORE INPUT BOXES POPS UP IF NO NUMBER IS SELECTED
    SOMETHING LIKE

    Code:
        Dim fs3, sf3, fl3, FldList As Variant    Dim i As Long
        Dim MyOption, FldCount As Long
        
        Set fs3 = CreateObject("Scripting.FileSystemObject")
        SubFolderName = "T:\Folder1\"
        Set fl3 = fs3.getfolder(SubFolderName)
        Set sf3 = fl3.SubFolders
        For Each fl3 In sf3
        i = i + 1
        FldList = fl3.Name
        Next fl3
        MyOption = InputBox("Enter Which Folder To Open ?" & Chr(10) & Chr(10) & _
        FldList, "SELECT FOLDER") IS IT POSSIBLE TO HAVE 8 numbers if 8 subfolders in the FldList ? ie: Enter 1 To Open Folder1 & Chr(10) & _ Enter 2 To Open Folder2 etc....
    THEN SOMETHING LIKE
    Dim fd As FileDialog
    Select Case MyOption
    Case 1
    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    fd.InitialFileName = "T:\Folder1" & "*.pdf*"
    With fd
    .InitialFileName = "T:\Folder1" & "*.pdf"
    If .Show = -1 Then
    .Show
    DoCmd.RunCommand acCmdAppMinimize
    End If
    End With

    Case 2
    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    fd.InitialFileName = "T:\Folder1\Folder2" & "*.pdf*"
    With fd
    .InitialFileName = "T:\Folder1\Folder2" & "*.pdf"
    If .Show = -1 Then
    .Show
    DoCmd.RunCommand acCmdAppMinimize
    End If
    End With

    PS: HOPE ALL OF THIS MAKE SENSE!!!

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    No, it doesn't really make sense.
    I have 't read your code properly so the following is a general response rather than a comment on your suggested approach.

    You have a working solution but want to change that to a much more clunky solution involving input boxes.
    These are far more limited in their scope and many developers like myself hardly ever use them.
    If I need something like that, I'll normally use a custom form so I'm not restricted in it's use.

    If you want to change your combo, I would suggest you consider using a listbox
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    DMT Dave is online now VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hi ridders52, yes i thought it would a touch more complicated, i guess i could have a hidden listbox if i still wanted to achieve, the first code (that works) is a separate event, i was goign to try and adapt the method.

    I think hidden list box and select the listrows onto an inputbox is more achievable..

    Thanks again for all of your help

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Now I am confused
    I meant use a listbox (visible) instead of the combobox and no input boxes at all
    But perhaps I'm missing the point of what you're trying to do
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    DMT Dave is online now VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hi ridders52, yes i can understand confusion! there isn't space on the form to place a list box, my target was to try and list a path of folders onto an inputbox, i already code for a different project where it populates folders to a combo, new project is nothing to do with that, but because i have already achieved the method, i was trying to use the same method and populate folder names to an inputbox instead of combo something like so the inputbox would say something like:

    COUNT FOLDERS IN T:\DMT"

    INPUT BOX
    Dim MyInput as Long
    Dim MyInput2 as Long
    MyInput = Inputbox("Please enter the folder you would like to open & Chr(10) & _
    "> 1 < For DMT\XL Files" & Chr(10) & _
    "> 2 < For DMT\PDF Files" & Chr(10) & _
    "> 3 < For DMT\Word Docs" & Chr(10) & _
    "> 4 < For DMT\Meetings" etc etc... Note: If Count Folders = 15 Then there would be 15 options on the 1st inputbox

    Select Case MyInput
    Case 1
    MyInput2 = Inputbox("Please enter the folder you would like to open & Chr(10) & _
    "> 1 < For DMT\XL Files\Job Sheets" & Chr(10) & _
    "> 2 < For DMT\XL Files\Time Sheets" & Chr(10) & _
    "> 3 < For DMT\XL Files\DMT Stock" & Chr(10) & _
    "> 4 < For DMT\XL Files\Customer Stock" etc etc... IF THERE ARE 10 FOLDERS Then 10 Input Options

    Case 2
    MyInput2 = MyInput = Inputbox("Please enter the folder you would like to open & Chr(10) & _
    "> 1 < For DMT\PDF Files\Delivery PODS" & Chr(10) & _
    "> 2 < For DMT\PDF Files\DMT SL's" & Chr(10) & _
    "> 3 < For DMT\PDF Files\On Hold" & Chr(10) & _
    "> 4 < For DMT\PDF Files\Customer Stock" etc etc... IF THERE ARE 13 FOLDERS Then 13 Input Options

    Case 3
    MyInput2 = Inputbox("Please enter the folder you would like to open & Chr(10) & _
    "> 1 < For DMT\Word Docs\Letterhead" & Chr(10) & _
    "> 2 < For DMT\Word Docs\Customer Quotes" & Chr(10) & _
    "> 3 < For DMT\Word Docs\Supplier Letters" & Chr(10) & _
    "> 4 < For DMT\Word Docs\Email Signatures" etc etc... IF THERE ARE 13 FOLDERS Then 13 Input Options

    Depending on what is selected in input and input2

    Dim fd as FileDialog

    Setup to open a dialog box to open

    Hope this is more sense!

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Up to you but I wouldn't use input boxes, partly because they are fairly primitive in appearance and functionality.
    If you don't have room for a listbox, I suggest a small popup form with a set of option controls or ... with a listbox!
    Using your own form will give far more flexibility.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    DMT Dave is online now VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Hi ridders52, yes i will go down the pop up form route as I may be able click on the folder in the list on the form and follow the path from there thank you for your help

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

Similar Threads

  1. How to make an Inputbox for report ?
    By ashraf.arafat in forum Access
    Replies: 4
    Last Post: 10-10-2016, 05:04 AM
  2. *** mask password in inputbox
    By Kvracing in forum Modules
    Replies: 13
    Last Post: 11-21-2014, 07:22 AM
  3. Inputbox
    By mladen273 in forum Programming
    Replies: 8
    Last Post: 12-29-2012, 05:32 AM
  4. Inputbox on programming? :(
    By radicrains in forum Programming
    Replies: 7
    Last Post: 11-05-2010, 10:58 PM
  5. Query & InputBox
    By RemusRigo in forum Queries
    Replies: 1
    Last Post: 03-25-2009, 08:21 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