Solved Help required "Want to Display Local drive folder through Command button in Access" (1 Viewer)

nexustech

New member
Local time
Today, 23:18
Joined
Oct 22, 2022
Messages
12
Hi Experts,
I want to access my local drive folder and displayed on the screen with the command button in Access, previously i had the below script for Excel to achieve that, but i am not able to replicate this in Acess , need support on this.

Sub sbOpeningAFolder16()

Dim FSO
Dim sFolder As String
sFolder = "C:\Users\aan\Documents\Aan\Performance " 'You can specify your Folder which you wants to Open

Set FSO = CreateObject("Scripting.FileSystemObject")

If Not FSO.FolderExists(sFolder) Then
MsgBox "Specified Folder Not Found", vbInformation, "Folder Not Found!"
ElseIf FSO.FolderExists(sFolder) Then
Call Shell("explorer.exe " & sFolder, vbNormalFocus)
End If

End Sub

Looking forward to prompting a response.
 

nexustech

New member
Local time
Today, 23:18
Joined
Oct 22, 2022
Messages
12
Is there a space after ".exe"? I think it needs one.
Thanks for your reply can you please advise where .exe should be?

Can you please create an access file with a button for me where the code would be running it would give me a better understanding, I am very novice to access. First time using through codes.
 

nexustech

New member
Local time
Today, 23:18
Joined
Oct 22, 2022
Messages
12
Thanks for your reply can you please advise where .exe should be?

Can you please create an access file with a button for me where the code would be running it would give me a better understanding, I am very novice to access. First time using through codes.
Hi

The_Doc_Man ,​

Thanks for connecting to help me out, as i am too new to this Access work i am sharing my file for reference , so i created this form and then added a but and in event option i entered the code. But when i click on design view to run it will not open the local drive folder.
Hope i m able to make sense for what i am saying.

looking forward for the feedback.
 

Attachments

  • Database21.accdb
    368 KB · Views: 64

nexustech

New member
Local time
Today, 23:18
Joined
Oct 22, 2022
Messages
12
Your code works. Whats the issue?
Hi Moke123, Please see my attached file , the code is placed in there but it doesn't executes for me ,not sure if i m missing some thing or what could be the reason.
 

Attachments

  • Database21.accdb
    368 KB · Views: 73

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:18
Joined
May 7, 2009
Messages
19,245
you need to add code to the Click event of your button.
see in design view.
 

Attachments

  • Database21.accdb
    476 KB · Views: 96
Solution

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:18
Joined
Feb 19, 2002
Messages
43,275
What is the objective of opening file explorer? Are you trying to import/export a file? If so there are more useful methods.
 

nexustech

New member
Local time
Today, 23:18
Joined
Oct 22, 2022
Messages
12
What is the objective of opening file explorer? Are you trying to import/export a file? If so there are more useful methods.
Thanks, Pat for raising the fact there are other useful methods. The objective is i want to do quick button access to some folders for my office work purpose without leaving the access dashboard I am willing to create.

Please share the other possibility and codes so I can try to see if they work for me.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:18
Joined
Feb 19, 2002
Messages
43,275
Here is an example with a couple of forms. There are two basic procedures called by the button with the three dots. One opens the file dialog so you can choose a specific file (you can add filtering so you see only spreadsheets or word docs or whatever) and the other opens the file dialog to let you pick a folder name.

Both procedures require a reference to a library - see the code for details.
 

Attachments

  • ImportFilesSample_20220122.zip
    2.3 MB · Views: 89

nexustech

New member
Local time
Today, 23:18
Joined
Oct 22, 2022
Messages
12
Here is an example with a couple of forms. There are two basic procedures called by the button with the three dots. One opens the file dialog so you can choose a specific file (you can add filtering so you see only spreadsheets or word docs or whatever) and the other opens the file dialog to let you pick a folder name.

Both procedures require a reference to a library - see the code for details.
Hi Pat, thanks again let me work on this to see how it goes.
 

nexustech

New member
Local time
Today, 23:18
Joined
Oct 22, 2022
Messages
12
So, you don't want to do anything with the folder once it is open??? OK, whatever.
Hi Pat, I was just looking to access the folders, I checked your code too, and it's very good you have an awesome experience, i would like to make products like that, just too newbie in this domain though.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:18
Joined
Feb 19, 2002
Messages
43,275
NP. It didn't make any sense to me to do this through Access if you had no need to import/export a file but whatever:)
 

KitaYama

Well-known member
Local time
Today, 22:18
Joined
Jan 6, 2022
Messages
1,541
It didn't make any sense to me to do this through Access if you had no need to import/export a file
I hear this magic word here frequently. For sure, something that doesn't make sense for someone, may make sense for someone else.
I really don't understand why some members can not understand different situations require different senses.

Our orders come in through an online system called EDI. The software downloads new order sheets to a specific directory in one of our servers.
The downloaded file name (depending on customer's country & locals) may have spaces, foreign characters etc. The users who register new orders need to edit file names, moving them to specific folders and do several more actions. Having a button on a form to take them to the download page is a great help for them. We can make a short cut on their desktops, but there's situations when one server having problems or is under maintenance and the download folder is moved to another server temporarily. Now we have to go to each PC and correct the short cuts.
Having a table as options and a record that saves the path to download page makes life easer for us. When the path changes, we just change this record in BE. One click always takes them where they need to go. No need to broadcast the path change via instant message, etc.

I can give you several more situations where we prefer to allow users to view a folder in explorer in a specific path.

I'm not OP and I don't know what he's trying to achieve, but I hope it makes sense for you now to see there may be situations when having a button to open explorer without import/export is beneficial.

With regards.
 
Last edited:

moke123

AWF VIP
Local time
Today, 09:18
Joined
Jan 11, 2013
Messages
3,920
Similar to KitaYama, I need to assemble various files for people which are downloaded to their individual folders. Rather than opening explorer to access them, I use fso to loop through the folder and populate a listbox on their profile form with the file names. A simple double click on the list opens the selected file.

Something like the attached
 

Attachments

  • Clients.zip
    91.6 KB · Views: 77
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:18
Joined
Feb 19, 2002
Messages
43,275
@KitaYama That's what the example I posted does. You can default to a particular folder and you can filter for specific file types. You can also do anything that explorer allows you to do like renaming the file. You are ultimately importing the file. The OP is NOT importing anything. He's just using Access to open explorer.
 

Users who are viewing this thread

Top Bottom