Senin, 31 Juli 2017

Re: [MS_AccessPros] Creating a folder structure based on combos?

 

hi Art,

adding on ...

Graham brought up some good points. If you do want to get a list the filenames, here is some code you can modify to dynamically populate a listbox or combo given a path (or not)

'~~~~~~~~~~~~~~~~~~~~~~~~~
'this is in code behind a form, Me
Private Sub LoadMyList( _
   psControlname As String _
   , Optional psPath As String = "" _
   )
'170423 s4p, 170731
   'set RowSource for Me.psControlname
   'load files from specified directory into listbox or combobox. For example:
   'Row Source Type = Value List
   'Bound column=1
   'ColumnCount=1
   'Multi-Select can be Simple, Extended, None
   '
   'options:
   'files could be loaded into array, with possibly other information too,
   '   and sorted on filename, size, date modified, or whatever desired
  
   'PARAMETERS
   '  psControlname is the Name of a control on Me
   '  psPath = path to read files from (default is CurrentProject.Path) '---customize
  
   Dim sPath As String _
      , sFilename As String _
      , iCount As Integer
     
   If psPath = "" Then
      sPath = CurrentProject.Path '---customize
   Else
      sPath = psPath
   End If
  
   If Right(sPath, 1) <> "\" Then
      sPath = sPath + "\"
   End If
  
   sFilename = Dir(sPath & "*.*")
   If sFilename = "" Then
      MsgBox "No files in the selected folder", , "No files found"
      GoTo Proc_Exit
   End If
   
   iCount = 0
  
   With Me.Lst_Files
      Do While sFilename <> ""
         If (GetAttr(sPath & "\" & sFilename) And vbDirectory) <> vbDirectory Then
            iCount = iCount + 1
            .AddItem sFilename
         End If
         'get next filename
         sFilename = Dir()
      Loop
   End With
     
Proc_Exit:
   On Error Resume Next
   Exit Sub
 
Proc_Err:
   MsgBox Err.Description, , _
        "ERROR " & Err.Number _
        & "   LoadMyList " & Me.Name

   Resume Proc_Exit
   Resume
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~

to call, for instance:

'~~~~~~~~~~~~~~~~~~~~~~~~~
   'load files from Desktop into a mult-select listbox
   'CALLS
   '   GetDesktopPath 'return path of desktop folder
  
   Dim sPath As String
     
   sPath = GetDesktopPath     'other folder could be specified, of course
  
   'Lst_Files is the name of a listbox control on Me
   Call LoadMyList("Lst_Files") ' sPath)
   
'~~~~~~~~~~~~~~~~~~~~~~~~~

and maybe you don't want to start with the desktop path, but in case you do, here is the helper function:

'~~~~~~~~~~~~~~~~~~~~~~~~~
Private Function GetDesktopPath() As String 'copy of public function
'170423 crystal
   Dim oShell As Object
   Set oShell = CreateObject("WScript.Shell")
   GetDesktopPath = oShell.SpecialFolders("Desktop")
   Set oShell = Nothing
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~

respectfully,
crystal
 
~ have an awesome day ~


On 7/31/17 2:25 PM, 'Graham Mandeno' graham@mandeno.com [MS_Access_Professionals] wrote:

OK, I understand.  God bless "Management" :-)

The next question then, is "Do you want to duplicate the hierarchy of folder and file names in the Access database (and risk it getting out of sync every time a file is added or deleted) or do you want to populate the combo/list boxes directly from the folder structure?

Best wishes,
Graham

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Tuesday, 1 August 2017 01:27
To: 'Graham Mandeno' graham@mandeno.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Subject: Re: RE: [MS_AccessPros] Creating a folder structure based on combos?

 

 

Yes, that is what the Management wants...

 


With Warm Regards,

 

Arthur D. Lorenzini

IT System Manager

Cheyenne River Housing Authority

Wk.(605)964-4265  Ext. 130

Fax (605)964-1070

 

"Anyone who claimed that old age had brought them patience was either lying or senile."  




 

 

 


On Sun Jul 30 2017 17:23:08 GMT-0500 (Central Daylight Time), 'Graham Mandeno' graham@mandeno.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

 

 

 

Hi Art

I can't help but think you are trying to reinvent the Windows File Explorer!

Is there any compelling reason to reproduce the file system folder/document hierarchy in Access?

Best wishes,
Graham

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Monday, 31 July 2017 03:40
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Creating a folder structure based on combos?

 

 

Currently writing a document management system in Access and would like to know if the following is possible:

I have my home screen called frmMain. On this form I have a cboCabinet (unbound - row source: SELECT tblCabinet.intCabinetID, tblCabinet.txtCabinetName, tblCabinet.txtCabinetLocation FROM tblCabinet; ) which is at the highest level of the hierarchy.

 

Then is the combo cboDrawer (unbound - row source:SELECT tblDrawer.intDrawerID, tblDrawer.intCabinetID, tblDrawer.txtDrawerName, tblDrawer.txtDrawerLocation FROM tblDrawer; which is the secondary level of the hierarchy.

 

Thirdly is my combobox cboPriFolder (unbound - row source: SELECT tblPrimaryFolder.intPriFolderID, tblPrimaryFolder.intDrawerID, tblPrimaryFolder.txtPriFolderName, tblPrimaryFolder.txtPriFolderLocation FROM tblPrimaryFolder; which is the tertiary level of the folder hierarchy.

 

Lastly is my listbox called lstSubFolder (unbound - rowsource:SELECT tblSubFolder.intSubFolderID, tblSubFolder.txtSubFolderName, tblSubFolder.intPriFolderID FROM tblSubFolder; This is the last level of the folder hierarchy.

 

on frmMain, this combination of combos and lstboxes is used to set the working folder.

 

So the following actions need to happen:

 

1. the root of the folder hierarchy is always c:\work but it could be mapped out to a server drive

2. I have a frmCabinets which the user use to create the folder hierarchy. At this point I need to the mechanics to create the actual folder structure based on the combination of combos and list boxes. ( I have uploaded a few snapshots of what frmMain and frmCabinets look like to the Needs Assistance folder.

3. Once the user sets the working folder, then I need to display a list of files in that folder. The user should be able to open any file in its natural application.

4. The application will need to remember the last selection in the combos and listboxes and working directory each time the user logs off and logs back in.

 

I know its a lot and as I go along I suspect I will have a lot more questions....

 

Thank you,

 

Art Lorenzini

Sioux Falls, SD

 

Ps. pictures will be uploaded shortly.

 


__._,_.___

Posted by: crystal 8 <strive4peace2008@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (5)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar