473,529 Members | 4,125 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File Dialog

4 New Member
I am very new to vb and Access and the like, please be gentle.

I am trying to use the below script in Access 2000 to open a file picker dialog then display the selected text in a text box. A friend helped me get it working on Acess2002 but i cannot get it to work on Access 2000.

Private Sub cmdFileDialog_Click()

'Requires reference to Microsoft Office 10.0 Object Library.

Dim fDialog As Office.FileDialog
Dim varFile As Variant

'Clear listbox contents.
Me.FileList.RowSource = ""

'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make multiple selections in dialog box
.AllowMultiSelect = False

'Set the title of the dialog box.
.Title = "Please select one or more files"

'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "Access Databases", "*.MDB"
.Filters.Add "Access Projects", "*.ADP"
.Filters.Add "All Files", "*.*"

'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = True Then
'Loop through each file selected and add it to our list box.
For Each varFile In .SelectedItems
Me.FileList.AddItem varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub



I have added the relevant object library but it still wont work. It hangs on the "Set fDialog = Application.FileDialog(msoFileDialogFilePicker)" line and on the "Me.FileList.AddItem varFile" line. Please help.

Josha
Sep 22 '06 #1
1 15681
PEB
1,418 Recognized Expert Top Contributor
Hi,

In my Access the same as yours, I don't have errors except:
Me.FileList.RowSource = ""
Me.FileList.AddItem varFile

Where maybe Me. replaces the current form that isn't present on my computer...

Before running this procedure please Compile your module in VB

If you can't call it as procedure replace

Private Sub cmdFileDialog_Click()

AS
Function cmdFileDialog_Click() AS boolean


To start it as function try in your code:

i=cmdFileDialog_Click()

Or in immediate window:
?cmdFileDialog_Click()

Have a nice day

:)

I am very new to vb and Access and the like, please be gentle.

I am trying to use the below script in Access 2000 to open a file picker dialog then display the selected text in a text box. A friend helped me get it working on Acess2002 but i cannot get it to work on Access 2000.

Private Sub cmdFileDialog_Click()

'Requires reference to Microsoft Office 10.0 Object Library.

Dim fDialog As Office.FileDialog
Dim varFile As Variant

'Clear listbox contents.
Me.FileList.RowSource = ""

'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make multiple selections in dialog box
.AllowMultiSelect = False

'Set the title of the dialog box.
.Title = "Please select one or more files"

'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "Access Databases", "*.MDB"
.Filters.Add "Access Projects", "*.ADP"
.Filters.Add "All Files", "*.*"

'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = True Then
'Loop through each file selected and add it to our list box.
For Each varFile In .SelectedItems
Me.FileList.AddItem varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub



I have added the relevant object library but it still wont work. It hangs on the "Set fDialog = Application.FileDialog(msoFileDialogFilePicker)" line and on the "Me.FileList.AddItem varFile" line. Please help.

Josha
Sep 22 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
6114
by: Mattbooty | last post by:
Hello, Not sure if anyone else has seen this bug, but I have a form where the entire form is covered with a picturebox. The picturebox has a mouseup event. I also have an open file dialog for loading images into the picturebox. If you double click the file you want to open in the open file dialog, it somehow interperets one of the clicks...
4
6246
by: Jonny | last post by:
Hello Group How do I open a Save File Dialog from an ASPX page behind a browse button? Any help would be fantastic!! I am using ASP.NET 1.1 using VB.NET as the coding language TIA
3
11067
by: Highlander | last post by:
Hello all. Consider the following HTA: <HTML> <HEAD> <TITLE></TITLE></HEAD> <BODY> <SCRIPT LANGUAGE="VBScript"> Sub ButBrowse_onclick() '-- show browse window and Get file path:
3
5200
by: ApexData | last post by:
I am using code from the following links to establish a Browse File and Browse Folder dialog. http://www.mvps.org/access/api/api0001.htm http://www.mvps.org/access/api/api0002.htm This code works great. However, once the file dialog becomes visible, if the user clicks on my popup form that exists under the file dialog, the file dialog...
1
3126
by: mvlt | last post by:
I am trying to create a button and related text box that allows a user to click, open the standard Windows File Dialog Box and populate the text box with the selected file path, which will then be a hyperlink. I can get the button to open the File Dialog Box, but when I close it returns "FileDialog(msoFileDialogFilePicker)" instead of the...
3
8375
by: Ecohouse | last post by:
I know how to use the File Dialog control but I'm not sure how to actually open the file that is selected. Here's my code: 'Create a FileDialog object as a File Picker dialog box. Set fd = Application.FileDialog(msoFileDialogOpen) 'msoFileDialogFilePicker ' Select Excel file for import With fd
2
1564
by: kronecker | last post by:
I have a short routine that writes to a wav file. The details of the wav write file bit is not important. At present it put a file dialog up and you type in a name for the file name and you save. Works fine. Actually I want this to be much easier and fix the file name to say file_name.wav instead of a dialog pop-up. How do I do this apparent...
4
3328
by: nightscorpion | last post by:
Hello Gurus, i implemented the OpenFileDialog in my Windows Form Applications and it worked perfectly fine.However when it was run on a remote desktop i got the below error . rt now im not sure where the problem is . is it something to do with any dll file which i need to include. if yes could u suggest me which dll files...
7
2487
by: xraive | last post by:
Currently I only get the file path. Is there way to retrieve the file name or do I have to just use the split function. Dim fDialog As Office.FileDialog Dim varFile As Variant 'Clear listbox contents. 'Me.FileList.RowSource = "" 'Set up the File Dialog.
0
7277
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7516
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7673
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7263
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5204
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3339
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
568
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.