Modules & VBA :: File Path Button
Aug 10, 2014I am trying to code a button to select a file path.I get a compile error: User-defined type not defined on the following line;
Code:
Dim fldg As FileDialog
I am trying to code a button to select a file path.I get a compile error: User-defined type not defined on the following line;
Code:
Dim fldg As FileDialog
In the access form I want to add a button with a special functionality.
After clicking "Select file" button special window should be open (or something else). It should give user a possibility of files locating (doc, pdf, rtf, txt ...).
After selecting the file and confirm the choice in the table "File_location" in database path to the file should be saved .
I have a field on a form which the user currently has to manually type in the file path to a specific picture on a local drive. After the file path is entered, the path is linked and the picture is shown in an image box. I did this because I didnt want to bog the database down with attached files.
I wondered if I could have a browse button, which when pressed brought up the browse window to allow you to locate the image (using the standard windows browser). Then when you clicked ok, it writes the filename into the correct field on the form.
I'm having another one of those days but I'm getting a file path and file name from a dialogbox and forgotten when the VBA property is to return the full file path and file name.
This code works fine for return the filename only:
Code:
Private Sub TEST()
Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
If f.Show Then
For I = 1 To f.SelectedItems.Count
MsgBox Filename(f.SelectedItems(I))
Next
End If
End Sub
Instead of using 'Filename' what else can I use to return what I need?
I'm importing a txt file using the following code.
Now my question is, how can I make visual basic ask me to select a file to get the path and put it in a string.
And use this string in the DoCmd.TransfetText
Code:
DoCmd.TransferText acImportDelim, "IN-specification", "tblimport", "C:usersKimdesktop extfile.txt"
Im trying to programmatically (without any user intervention) retrieve the long path name for a given file. It seems to me this should be a rather easy thing to achieve using Access VBA. Ive tried using various FileSystemObject methods with no luck. Ive Googled many variants of VBA get full path without any meaningful hits. provide the first string as a parameter to some object and have it magically return the second string.
String 1: C:PROGRA~2COMMON~1MICROS~1VBAVBA7VBE7.DLL
Stint 2: C:Program Files (x86)Common Filesmicrosoft sharedVBAVBA7
I've recently created a new Access 2010 Database which I'm developing an interface for in VBA. I've created a new Userform in the Visual Studio (this required me to add the Userform button). I'm finding that when I insert the Multipage object which I need to use on the form I can no longer run the Userform. When I attempt to run, I get the error 'Path/File Access Error' followed by 'Run time error 75 - Could not find the specified object'.
It's definitely linked to the Multipage which I've inserted from the toolbox (standard object) as the form runs fine when it is not there and with other objects (have tested all other toolbox items). There is currently no code in written in the project, no tables or queries set up in the database therefore nothing is running when the form loads.
I've successfully used Multipages in a number of other VBA interfaces both in Access and Excel so not sure why they are causing a problem here. I've also just created a userform in exactly the same way in a new Excel sheet and it runs fine with the multipage.
I am using MS Access 2010. I have a code that I am using that loops through a folder gather all the names of the files in the folder and inserts them into a table (shown below). The table is named "tblFiles" there are two columns in the table titled file name and file path. What I want to do is to also loop through the same folder to find the file path of the files and insert them into the file path column has a hyperlink where users can just click on the hyperlink and the file opens.
Private Sub Form_Load()
Dim fs, f, f1, fc, s
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("tblFiles")
[Code] .....
I have the code below and I want it to open a file from my documents folder. The only problem is that every computers path is different to this folder. Any easy way to work around and open a file in My Documents without the full path?
I want to eliminate the part of the path in red and make it universal because computers will have a different number.
Operating System: Windows 7
Code below:
Public Function AddITARPicOffloadAnalysis()
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
With xlApp
Dim wb As Object
Dim ws As Object
Dim Lastrow As Long
[Code] .....
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've got the forms and queries in one .accdb file and my tables in a separate .accdb file. The forms file links to the tables in the tables file. The tables file resides in a folder called simply enough C:acc_tables and thats where i browsed to (obviously) when i set up the linkage.
One of the users does not wish (for whatever goddamn reason) to create a C:acc_tables file to stick the tables file in , and wants the tables file in some other folder.. Unfortunately this user does not have the skills to delete the existing links and re-link to the tables file after putting it in the folder he wants.
Where in the file that holds the forms and and queries do i find the path setting to the tables linked file? Can it be changed without deleting links and then re-linking?
I want to open different .doc files by a button from access.
I want that the vba code checks where the current access database is located. In which folder the the current access database is.
In this file folder i have a folder called documents.
In this folder i have the .doc files.
Right now i have the following code.
Public Function getPath(ByVal iPath As String)
Dim fso As Object
Dim drive As String
Set fso = CreateObject("Scripting.FileSystemObject")
drive = fso.GetDriveName(CurrentDb.Name)
[Code] .....
The access database is in the folder Z:BUS MMM CGrimmMasterarbeitDatenbank
I would like to have something like
spath = getpath("documentswissen.doc")
How can i do that?
I have been searching all over on how to create an import button on a form in access 2010 where I can set which table it should copy the data into but the user could locate the import file.
NOTE: the reason being I have locked all the ribbons...
If necessary I could make a specific import template file which would have all the headings locked...
Is it possible in access, to create a button that will copy a file to a new directory? Specifically, the data field in question is an access hyperlink that we can click on to open a PDF drawing of a part. I just want to copy the file the hyperlink points to, into a new directory.
EX:
X:database/drawings/somefile.pdf
X:erp/drawings/somefile.pdf
I don't think a macro can do this, but perhaps vbscript can.
I have a button that allows a user to select a file using the windows select file dialog using the following code:
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Title = "Select A Text file to Import"
.Filters.Add "Text File", "*.txt"
.FilterIndex = 1
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .Show
If (result <> 0) Then
Me!txt_path = Trim(.SelectedItems.Item(1))
End If
End With
Is there a way that I can capture the path of the file they select in a separate text box?
Thanks!
Vassago
I went to the Microsoft knowledge base (304408) and found a routine that automatically logs off users with a short warning. It works fine, but depends on the presence or absence of a small text file which is named chkfile.ozx. The file is referenced in a form timer function as follows:
Dim StrFilename as String
strfilename = Dir("c:MyDirectorychkfile.ozx")
The function then tests for its presence and does its thing. You trigger the logoff by going in as sysop and changing the name of the file so it is no longer found.
The problem I have is that on the network, I use the backend file on the network and different users map different letters to it. I get around this by linking using UNC eg. \ServerNameSYSData_be.mdb.
I put the chkfile.ozx into this directory since all users presumably have access to it.
I tried changing the trigger function to
strfilename = Dir("\ServerNameSYSchkfile.ozx")
but the program doesn't recognize the presence of the file. When I map it as "F:SYSchkfile.ozx" it works, but since all users will not be mapped to "F", it really isn't a solution.
Does anyone know the proper syntax to include in the Dir method for UNC naming?
Hi,
I nave a code which allows the user to upload a file to a folder "images". I want to be able to record the filename and path in a table called "attachments". But I am not sure how. Can anyone help
Private Sub Command0_Click()
Dim FD As FileDialog
Dim Name As String
Dim Name2 As String
Dim Pathx As String
Dim Path As String
Pathx = Me.Application.CurrentProject.Path & "Images"
Path = Me.Application.CurrentProject.Path
Set FD = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtSelectedItem As Variant
With FD
.AllowMultiSelect = False
'Add a filter that includes GIF and JPEG images and make it the second item in the list.
.Filters.Add "PDF", "*.pdf, 1"
'Sets the initial file filter to number 2.
'.FilterIndex = 2
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
Name = Dir(vrtSelectedItem, vbSystem)
Name2 = Pathx & Name
If Name2 = vrtSelectedItem Then
Else
FileCopy vrtSelectedItem, Pathx & Name
End If
Next vrtSelectedItem
Else
End If
End With
Set FD = Nothing
How can i let a db find out the folder path, without its own file name, and save it in a variable?
merci
i am using file browser to save a file in MS ACCESS forms. However, i want another file browser to allow the user to specify the folder he wants, then from the folder he selects, i will generate a series of codes. Any advice on How can tat be done?
thks
FT :)
I have a button which runs a list of queries that take roughly 10 seconds to run, when another user clicks the button while the other one is running it gives and error message 3405, File already in use.
View 1 Replies View RelatedBasically im trying to setup a click button that will export my query as a text file ( the text file will then be fixed width and i have already setup the specifications for this).
I think i get how to complete the export part as below
OutFilePath = "file location i want the data to be exported to"
DoCmd.TransferText acExportFixed, "Welcome output query Export Specification", WelcomeOutput, OutFilePath, True
I just dont know how to run the query and link it to the export.
I am trying to create some code for a button in a report that will follow a hyperlink to a specific file. The problem I'm having is that the files that are at the end of the hyperlink can have various extensions (*.doc, *.docx, *.pdf, etc.) I'd like to be able to put a wildcard in the code to allow the opening of the file regardless of the extension.
Code so far:
Private Sub Command6_Click()
Application.FollowHyperlink ("C:UsersjbeggDocumentsAccessTestFolder" & [FileName] & ".*")
End Sub
So Access was unable to manage the amount of content that I needed to produce in a single report. The reports contain 12 charts/graphs all of which I needed on separate pages (one chart per page). As such I could not create large enough charts in access to fit to each page, as Access limits the amount of space one can use in a report.
I downloaded Microsoft Reports Builder 3.0 and built my reports as needed and can generate them as desired at current. I'm wondering if there a way to call that RDL file I created to generate my reports from a form control button in Access?
Hey guys,
How can I change the tables' splitted file path via vba?
Ex.: c: ables.mdb -> c:ew path ables.mdb
thank you.
Hi, I have a command button that opens a pdf file. However i will be distributing the database as a runtime package and need to account for people having different versions of adobe reader so need to search for the filepath string where Acord32.exe is found. This is the code I have but I am stuck! Ay help aprpeciated!
Private Sub Command4_Click()
Dim stAppName As String
Dim stPathName As String
Dim fs As Object
Set fs = Application.FileSearch
With fs
.LookIn = "C:Program Files"
.SearchSubFolders = True
.FileName = "AcroRd32.exe"
.Execute
????? stAppName = .FoundFiles
Set fs = Nothing
End With
'specify path name for version of adobe acrord32.exe
'stAppName = "C:Program FilesAdobeReader 8.0ReaderAcroRd32.exe "
stPathName = GetIniSetting("C:WINDOWSSSI_DL3_PROGRS.ini", "DIR", "REPORT_FILELOCATION") & "HOOF.pdf"
Shell stAppName & stPathName, vbMaximizedFocus
End Sub
Hi there!
I have a question:
Is it possible from a form to have a field (hyperlink - I suppose) where when the user cliks it opens windows prompt (like when you do a "Open" in a word document) and the he/she can select a desired file/folder then click OK (or something) and it puts the exact path to the previously selected file into the field!
Do you get what I mean? Is this possible?
Thank you for your help