Modules & VBA :: How To Open Treeview Node To A Specific Folder / Subfolder
Dec 18, 2014
I have a tree-view object that is filled with a specific folder list, when a command button is pressed I would like too expand to a specific node based on a variable/foldername.
How to achieve this? My knowledge of tree-view is limited and I am still learning VBA.
I'd like to expand me tree view automatically when a node matches a string variable from a table. In other words, when a node in a tree matches the given name (variable), the tree will expand all the way down to that name. I guess I need to use "For each node" and when the node and variable match, the tree structure will show up.
I have come up with something like this:
Code: For Each nd In Me.tree.Nodes If nd = level1 Then nd.Child.EnsureVisible Exit For End If Next nd Me.tree.SetFocus
But this only shows the first level of my tree ( btw. I have a 3 level tree). I get lost inside the FOR when I want to make use of another two variables - level2 and level 3
I'm having problems creating a second subfolder in the main folder.
The main folder is used to keep inside the reviews of clients inside.
The code I have now, will only create a main folder if it does not exist and then a subfolder with the BIN nr, type review and date. If the client would have a diferent ones and in diferent years. So if it has first "Prototype Model", the next one could be "Prototype Review". The part of the code that checks if the main folder exist works, but how to let the code create in the main folder the second review subfolder? Please see below code I managed so far:
Code: Private Sub btn_Create_Folder_Click() 'XXXXXXXXXX working onXXXXXXXXXXXXXX Dim path1 As String Dim path2 As String path1 = "C:Test_FolderMedium" & Me.BIN & "_" & RTrim(Me.LE_Name) & "" path2 = "C:Test_FolderHigh" & Me.BIN & "_" & RTrim(Me.LE_Name) & ""
I'm venturing into the abyss of treeviews and have read many threads on this subject. I have two questions to ask regarding the attached sample db, if anyone can help me please.
1) How can I adapt the existing code and create subnodes (or sub child nodes). For example, how can I create a sub-node of OPEN FORM2? 2) What is the syntax for an ONCLICK event, i.e. by clicking on OPEN FORM2 I want it to open FORM2?
I downloaded a sample treeview application I have modified most of its to suit my need, except one thing. I want link parent/child node the main form to the main form through a subform on the CategoryID.
The following is the original code where when a child not is clicked only pops up a "linked" msgbox. I need to modify the part of the code on the Select Case "C" in red:
Code: '---------------------------- Sub DisplayForm(i As Integer) '---------------------------- ' for this Treeview I do not want a double-click on a parent node ' to open the applicable Category form, but pressing the shift key ' should open the marriage form applicable to the parent node. Shift ' or double-click on a child node should open the applicable ' offence form.
Dim strKey As String Dim strTag As String Dim strFilter As String
I'm trying to open a folder based on a BIN nr. This folder could be in a main folder that has diferent subfolder. As there where differnt naming used to create the folderes, one of the things they have always is the BIN nr. It alwasy start with a unique number and maybe I could use it to scan the subfolders and open that one that the BIN nr is equal as in the field BIN.
Now we have serveral 1000th of folders and finding them takes time.
Open a specific Windows Folder.I am using this code to open a specific Windows folder ..... and it works perfect:
As String Dim folder folder = "c: Documents WORD" Dim Retval Retval = Shell ("explorer.exe / e, / root," "" & folder & "" "", 1)
... but also need to open in the specified path, taking the data "UserName" of one field in a table:
TABLE: "Assignments" IDEExp, UserName, Date
So instead of going to the folder = "c:Documents WORD" would go to: c: Documents WORDUserName ". In Windows and subfolders are created with UserName1, 2,3,4, etc.
I have 3 attachment boxes in my table that appears in a form.each attachment box contains specific files (not specific as in extension such as PDF, JPEG, etc.) but specific as in Company Documents, Certifications, Resumes. The issue is there's a lot of document and I see my database growing (fast)...My question finally is....
Can I use a Hyperlink to open a folder within a specific directory where multiple file are located so i can open the specific file need there RATHER than attaching them in the attachment box individually?.?.....If not how this can be done (no SQL) unless that route is very simple and basic coding.
My thinking would be to place the file path to the documents in the table and hyper link that column in the table, but not knowing exactly how Hyperlinks work I don't think it would actually work..
In order to act as a system, I would like to have a function or windows firstly displayed all the folder names in a drive, and then allow user to locate/select freely a folder among different folders. Is there anything for my reference or for me to start??
In VBA I have set a timer on a form to run a query and export to a specific folder as an excel file.
If I open the database as 'File Open' and open the form and let the timer run it exports perfectly.
As soon as I put the database into runtime - the Timer code kicks in and starts running but as soon as it hits the export line. It stops and then does nothing
I have some code set up to automate scanning from access to a specific folder on the server. I have searched the web for different codes and have not come across anything that will scan an unknown amount of documents. The best I found was the code I am currently using, that will scan up to 10 documents separately, then convert these documents into 1 PDF. This is not ideal, however, because it would require the user to scan 1 document, wait, than scan another, wait, etc. Also, the code I am currently using will only scan from the glass, not the auto feeder, and I am unsure how to change this.
Private Sub cmdCOC_Click() 'scan COC On Error GoTo Err_Handler Const DEVNAME As String = "Brother MFC-7860DW LAN" Dim ComDialog As WIA.CommonDialog
I'm trying to automate a process of selecting a set of file/s and move them in a folder. When I click on a button, it should open a current folder that is setup in the code.
Lets say that I have a folder C:documents est, and very time I click on the button, it should open the dialog box with that path so I can select the files from another folder, drag them there and they will be saved in that folder.
This will form part of wider automation that will send an email stating that those file/s where placed in that folder.
I have in the same form where the button is placed, 3 check boxes that needs to be passed to the email as well that one or all the files where placed in the folder.
I am trying to display an open file dialog window so that the user can pick up a file. I wish the window to show a specific folder. How can I do this? The code I am using is below. The parameter InitialFileName has no effect on the outcome.
Code: Function GetFileName(strPath As String, imtype As String) As String On Error GoTo Err_GetFileName Dim Dlg As FileDialog Dim sfl As FileDialogSelectedItems Dim sflitem As Variant Set Dlg = Application.FileDialog(msoFileDialogFilePicker)
I am 2 years into my database. I am trying to find and open a folder based on a text box. The problem is folder could be in many sub folders which is hold on our J: drive.
To further complicate, the folder i am searching may not be exactly as the text box states.
EG. Text box could say 123456 however the folder could be called M123456 etc.
How do i locate a folder or subfolder and open it based on part of a text box...
I have a folder which holds 1000s of pictures organised in subfolders, for example:
D:~AI Database Print Scans2009family and D:~AI Database Print Scans2009holiday
And so forth. In total at the moment 17 main subfolders, each of which hold another 2-3 subfolders.
I am putting together a database to bring pictures together with all sorts of details. I import the picture via hyperlink and complete the various fields. All that works fine but there are a lot of pictures! And it gets confusing to see which ones have already been entered into the database and which ones haven’t.
One solution for this is to copy the pictures that have been “completed” to another folder. I have found a way to do that:
Dim fs As Object Dim oldPath As String, newPath As String oldPath = Forms!frmPrintDetails.txtPath1 newPath = "D:~AI Database Print ScansCompleted_Entries" Set fs = CreateObject("Scripting.FileSystemObject") fs.CopyFile oldPath, newPath Set fs = Nothing
Works fine, but the problem is that I loose the subfolder structure, it copies all pictures to the same main folder. I’d like to maintain the subfolder structure and add code to create the correct subfolders and next copy the picture. With the different paths I’m lost. I don’t know how to extract the correct path in code. I’d also like to either rename or remove the picture once I have completed entry of the details. The problem I have again is that I don’t know how to code for a changing path.
I have a form that is opened as hidden when my startup form loads. Data gets entered into it from other forms so whenever I switch records the hidden form needs to be opened to the matching record.
To accomplish this, I have been using the DoCmd.OpenForm in the OnCurrent event with the WHERE clause matching the PK/FK. I have had no luck with the SearchFor method.
It seems silly to have to keep reopening a form to go to a specific record when the form is always open already. Plus, I am wondering if it is affecting the forms' load times.
Is it possible to use VBA or macros to open a table to a specific record?
I know how to open a table in database view using a command button. I'd like to have it open to or automatically scroll to and select a specific record, based on the content of the form. This way I don't have to spend time scrolling through the whole table to try and find the desired record.
I am still trying to copy an Excel file from a parent folder to a sub-folder, that this code creates, and name the copied file with the name used to name the sub-folder, using the name entered in a control field (named 'TheDirName) of an Access 2007 form. Here is my VBA, which names the copied file "TheDirName.xlsx.:
Private Sub MakeDir_Click() Dim appExcel As Excel.Application Dim lngLastDataRow As Long Dim Folder_Path As String 'Create path for customer folder & files
I have a from that has information icons that opens a separate form to support users make the right choice on a form. With each information form users are able to choose "Yes" or "No" and then it returns them back to the form they started. I am having trouble setting the focus to the control the user original left the form from.
Form A Control 1 Control 2 Control 3
Form B Information for Control 1
Form C Information for Control 2
Form D Information for Control 3
For Forms B - C I would like the form to close, open Form A and then set focus to the control that the form was providing information for.For example, if you are on Form C and you make a decision, I want Form C to close, Form A to open and focus to be set to Control 2.
Code: Private Sub image5_Click() Dim sWHERE As String Criminal_Background.Value = "Yes"
The code below allows me to open a publisher document that is already merged to the current record. What I need is to allow the user to open the document according to the group they are reviewing. How to accomplish this?
For example:
IF Group = A1 OR B1 THEN OPEN AB_1.pub IF Group = A2 OR B2 THEN OPEN AB_2.pub IF Group = A3 OR B3 THEN OPEN AB_3.pub
Dim pubApp As Publisher.Application Dim pubDoc As Publisher.Document Set pubApp = New Publisher.Application Set pubDoc = pubApp.Documents.Add.Application.Open("c:Publishe rAB_1.pub) pubDoc.ActiveWindow.Visible = True
We have an access database which has a form that has a list box that details particular records. See attach "list box".
What I would like to do is double click on the record and this would look in a powerpoint folder (see attach "path") and open the presentation if there is a match to the value in Listbox Column 5 i.e. Tool Number.
I can get it to open the presentation if I include the tool number in the path but I cannot seem to be able to get it to compare the values and only open if there is a match.