A family of Microsoft relational database management systems designed for ease of use.
Did you try the suggestion I made?
While Abdal's solution can work, it is using a cannon to swat a fly.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a datatbase of photograph file names. In the DB I have a List Form that has a "Digital File Name" field. Question: Is it possable to create a command button on my List Form that will open the photo (that is stored in my Photos File on my C: drive) based on the digital file name for the selected record?
I am using Access 2016
Thanks Walt
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Did you try the suggestion I made?
While Abdal's solution can work, it is using a cannon to swat a fly.
Abdal,
Thank you for your reply. I tried the code you suggested and it would not work for me. When I clicked my Open Image command button nothing happened. Following is the code I wrote as copied from the Code bulider page of the Open Image command button:
Private Sub cmdOpenFile_Click()
Dim fso As Object
Dim filePath As String
'Get the value of the "Digital File Name" field
filePath = Me![Digital File Name]
' Construct the full file Path
filePath = "D:\Documents\Family Tree Maker\Wright-Jagoe(1) Media" & filePath
' Create a FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject')
' Open the file
fso.GetFile(filePath).Open
End Sub
I must have made some mistake as I am not to far advanced in Access, although I do follow directions pretty well.
Hope you can help - Walt
Sure, it real easy. I'm assuming here that the Digital File Name includes the full path and filename. So what I would do is use the Double click event of the control bound that field and use this code:
Application.FollowHyperlink Me.txtFilename
Where txtFilename is the name of the control bound to the field. This will open the fiel in your default photo editor.
If you only store the filename and not the full path, you sould need to do something like:
Application.FollowHyperlink "C:\photos" & Me.txtFilename
Alternatively, you could simply add an unbound image control to the form and set the Controlsource to the field.
Hello
I am Abdal and I would be glad to help you with your question.
Yes, it is possible to create a command button on your List Form that opens the photo based on the digital file name for the selected record. You can use VBA (Visual Basic for Applications) code to accomplish this. The code would use the FileSystemObject to open the file and the value of the "Digital File Name" field to construct the file path. You can then assign the code to the On Click event of the command button. Here is an example of code that you could use to open the file:
Private Sub cmdOpenFile_Click() Dim fso As Object Dim filePath As String
' Get the value of the "Digital File Name" field filePath = Me! [Digital File Name]
' Construct the full file path filePath = "C:\Photos" & filePath
' Create a FileSystemObject Set fso = CreateObject("Scripting.FileSystemObject")
' Open the file fso. GetFile(filePath). Open End Sub
You would need to replace 'Digital File Name' with the name of your field and the 'C:\Photos' with the path of your photos directory.
I hope this information helps.
Regards,
Abdal