Can you tell me how to make an attach button?
I want to be able to click on the button and the window to search for file will appear, here I choose the file and the path of the file appears in a textbox just to the left of the button.
If you go to Allen Browne's site, I don't have the link handy but I think AllenBrowne.com, and look for the function which from memory is called FileList or ListFiles.
One version of it puts all the files (and full path) in a table. The file name goes in one field and the path is placed in another field
Once you have the file name and path in a table then you can go from there
If you go to Allen Browne's site, I don't have the link handy but I think AllenBrowne.com, and look for the function which from memory is called FileList or ListFiles.
One version of it puts all the files (and full path) in a table. The file name goes in one field and the path is placed in another field
Once you have the file name and path in a table then you can go from there
I tried to make that tutorial but I didn't understand the code that much.
I don't see how the modulee helps me when I press my button. Shall the button open the module or what?
I don't have his site in front of me but on the ListFiles section a few lines down there is a second one to list the files to a table, that is the one you use. His code is ready to go when pasted in a module and you make the table as per his instructions.
Once you have the file names and paths in Access records you can do what you like.
It can be used for all sorts of things. I call his function on a dynamic bases, that is, the folder where the files are to be listed from is an entry in a textbox like
A dynamic system is also needed if you wish to open files or display folders when the file names and paths are storeed in Access fields.
With most of this this stuff like the ListFiles, Lebans converting Reports to PDF and others, you sandwich what they have made between you stuff and sometimes change a bit of theirs but I used the code for the ListFiles as is and just stick it in between what I want to use it for.
Edit PS. A good way to learn about doing things on a dynamic basic is to search around (Google is a good starting place) for how to save files with a date/time stamp and how to reopen such files. You will usually find that searching around for how to one thing will end up leading you down all sorts of roads
Thank you for the help. It was a little difficult to make that, but I managed to do it in another way, almost like Allens example.
The thing I didn't fix here is how to be able to click on a table post(inserted file) and then get the file opened.
You need to have a continuous form or combo display the records.
I prefer a continuous form and one button has the code to open files such as Word or Excel and the other button has as its onClick inserting the file name as the hyperlink address property. A click will set the hyperlink address and open the file a the same time. That is to open files such as PFDs but will of course do Word.
The cosde on AllenBrownes site is just a paste into a module. You don't need to do anythingto it except make the little table as per the instructions.
Change the pdf to doc etc as required and of course the name of your form, button etc.
You can do this different ways to suit yourself. For example, in my case I store the file name in the Access field but without the extension and hence the + ".pdf"). I could also store the extension in an Access field and in that case the + ".pdf") would be repalced by something dynamic.
But in general it is best if you make the whole thing dynamic. In other words the way I do it is not the generally accepted way as it is not all dynamic.
I don't use hyperlink for Word or Excel because when you open a Word or Excel file with hyperlink you can't do anything with it such as insert data from Access.
The thing is, I want to copy the files into a specific folder that I've made before with MkDir. I want to use FileCopy(Source, Destination). When I click on the file to open, how that works I don't know yet, then the file which is copied shall be opened. Not the source file beacuse that can be from an flashdriver.
I've come so far where I can upload a file and the path appears in a field in a table. When I upload a file, I can also choose which group the file shall be placed as. The group is a coloumn in the same table as the one which saves the path. The group is like a ID for many files or like a tagg, and it is shown as a dropdown menu.
These three sentences from your first post made me question the reason for the project: -
(I have bolded the words that drew my attention to it.)
>>All folders shall be editable and you may put new files(pictures, documents etc) and also delete old files.<<
>>You shall also be able to search for some specific file and from the database also open the file.<<
>>Everything shall be made through forms in the access database.<<
From the point of view of a company instruction this would seem to apply… Shall is perhaps in uncommon usage here. You implies that the only person required to be able to use the database is you.
To me, a company should be instructing that the database be built for its employees not just the person who is writing it.
Yet when I read them as instructions for a student they appear to be okay to me.
---------------------------
Another point…
You mention a database but fail to say if that database will be split. If you ask people around here they will suggest that it should be split.
This has an immediate implication as to where the folders should be created. It would be uncommon to create folders relative to the FE in a multi-user system.
This would lead to files being shattered all over the network and would have limited benefit in a multi-user company database.
Therefore I think that CurrentProject.Path would not be a suitable method as it would use the FE as a reference point rather than the BE on the server.
To use the BE as a relative path you can use the Table linkage information as derived from the ‘Database’ (yes it’s a reserved word but blame Microsoft for that) field in the MSysObjects table. It will either be based on a drive letter or UNC (preferred) path depending on the method used to link the BE tables to the FE.
---------------------------
Another point…
Again, in my view, the MkDir Statement is not worth using at all if the intension is to make sure that a directory exists. It can only build one level of directory at any one attempt and will error if the directory already exists. Therefore, a test needs to be made if the directory already exists prior to trying to make it. That requires more code and that code can bring with it its own errors.
So I will suggest that the ‘MakeSureDirectoryPathExists’ API call be used: -
Code:
Option Explicit
Option Compare Text
[color=green]' KPD-Team 2000
' URL: http://www.allapi.net/
' E-Mail: KPDTeam@Allapi.net[/color]
Public Declare Function apiCreatePath Lib "imagehlp.dll" _
Alias "MakeSureDirectoryPathExists" (ByVal strPath As String) As Long
Public Function CreatePath(ByVal strFullPath As String) As Boolean
If Right$(strFullPath, 1) <> "\" Then strFullPath = strFullPath & "\"
CreatePath = apiCreatePath(strFullPath)
End Function
Sub TestIt()
CreatePath "C:\Some nonsense\Test1\Test2\Test with an apostrophe '\and another test _"
End Sub
---------------------------
The final point I would like to make…
Nothing, other than generic solutions, can be provided in this thread or in this Forum for that matter.
The information given to us by you, and to you by your company, is totally inadequate.
There is no point in starting a database project without knowing the ‘business rules’ that will be applied to it, not just now, but also in the future. (Admittedly difficult.)
It must be your company that provides those ‘business rules’, not us.
But that’s it from me because there’s an old question; “How long is a piece of string?”
The answer being; “That depends on if you are pushing it or pulling it.”
Of course, I think all of what you wrote is correct.
The thing is that I am employee just to make a database for the company then I move on somewhere else. So, I haven't got that much information about the company rules and policy. But of course that shouldn't even be informed to me, that is a thing I should know before I start working with the database.
About my choose of words, as those you questioned, shall and you.
First I would like to say that I'm very glad you told me how people may translate those words. It will pretend me from writing them further on.
Second, the mainreason of my bad selecting of words is that I'm not that professional in english. But I'll try to write more carefully next time.
I would really appreciate some help with these problems.
The first one:
I am trying to make a button that copies a selected file to another directory.
I'm using this code:
Code:
Dim strFolder As String
Dim strparm As String
Dim strdestination As String
strFolder = Me.ddpärm.Column(1) 'this is the directories as a dropdown
strparm = Me.FilePath.Value 'this is my textbox with the filepath
strdestination = (CurrentProject.Path & " \ Pärmar \ " & strFolder)
FileCopy strparm, strdestination
I would also like to add a popup box if strFolder is not selected, (null).
The other one:
Now I want to be able to open those files by pushing a button in another form. The button shall take the path of the table and open it, no matter what sort of file it is(picture, word document, pdf etc).
I think you already have several answers. For example:
The other one:
Now I want to be able to open those files by pushing a button in another form. The button shall take the path of the table and open it, no matter what sort of file it is(picture, word document, pdf etc).
On post 27 and 28 I showed you how to open files with hyperlink and button.
I would suggest that you make a thread and confine that to a single problem. Attach an extract of the data base relevant to that problem and illustrating where you have a problem. Make the extract of your data base as small as possible. So if you have a form with buttons and fields all over it then make a small version of the form that only has the fields and buttons that are relevant to the problem.
As Chris mentioned you will only get generic solutions and also in general solutions that are basic solutions. In other words it is then up to you to build around the solution or include the solution in what you are wanting to achieve.
You can actually just subscribe to the thread without posting, if that would work for you. At the top of the thread, there is a dropdown for THREAD TOOLS and you can select Subscribe. Just thought I'd mention it helps.
You can actually just subscribe to the thread without posting, if that would work for you. At the top of the thread, there is a dropdown for THREAD TOOLS and you can select Subscribe. Just thought I'd mention it helps.