473,397 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Prompt a user for a file in Access

9
I have been trying to prompt a user for a file name. I'm using the code below but keep getting the message "compile error: Method or data member not found". It is stopping on the Application.FileDialog line. Any help would be greatly appreciated!!

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command13_Click()
  2.  
  3. Dim myDialog As FileDialog
  4. Dim strFile As String
  5. Dim strSearchPath As String
  6. Dim vrtSelectedItem As Variant
  7. Set myDialog = Application.FileDialog(msoFolderPicker)
  8. 'Use strSearchPath  if you want to start in a particular directory. You can leave it out if you wish (as I have it commented out right now) and it will start with a default directory of Windows choosing.
  9. 'strSearchPath ="C:\SomeDirectory\SomeSubDirectory"
  10. With myDialog
  11.     .AllowMultiSelect = True
  12.      .Filters.Add "Excel Files", "*.xls", 1
  13.     .Title = "Please Locate the Files to Import!"
  14.     .InitialFileName = strSearchPath
  15.      If .Show = -1 Then
  16.  
  17.     For Each vrtSelectedItem In .SelectedItems
  18.       'I pass the file information to another routine that handles the transfer
  19.       ImportIt (vrtSelectedItem)
  20.     Next vrtSelectedItem
  21.         MsgBox "All data imported into the NewData Table." & vbCrLf & vbCrLf & "We will now post any new data into the data table!"
  22.         Else
  23.         'The user pressed Cancel.
  24.         End If
  25.    Set myDialog = Nothing
  26. End With
  27.  
  28. End Sub
May 24 '07 #1
7 4605
NeoPa
32,556 Expert Mod 16PB
Try using (msoFileDialogFolderPicker) on your line number 7.
Expand|Select|Wrap|Line Numbers
  1. Set myDialog = Application.FileDialog(msoFileDialogFolderPicker)
May 25 '07 #2
NeoPa
32,556 Expert Mod 16PB
Try using (msoFileDialogFolderPicker) on your line number 7.
Expand|Select|Wrap|Line Numbers
  1. Set myDialog = Application.FileDialog(msoFileDialogFolderPicker)
I got that from the help, but when I went to Debug.Print it there was nothing.
Confused, I found that the Reference to Office (Microsoft Office 11.0 Object Library or version equivalent) is required to use it. Make sure you have such a reference in your Access set up, and make sure it is also available for all computers that expect to run your project.

Good luck.
May 25 '07 #3
bae14
9
That helped. Thanks! BUT, now I get a "run time error" '438'. It says the object doesn't support this property or method. It is stopping on the Filters.Add line. Any ideas? Thanks a lot for your help.
May 29 '07 #4
bae14
9
Actually my code passed through the error and got to "ImportIt" and says the sub or function not defined. Any help on this one rather than the one I just posted? Thanks!
May 29 '07 #5
NeoPa
32,556 Expert Mod 16PB
Actually my code passed through the error and got to "ImportIt" and says the sub or function not defined. Any help on this one rather than the one I just posted? Thanks!
As far as I can see there's no procedure ImportIt defined.
Please use the line numbers in future when referring to your code. It makes life a bit easier.
May 29 '07 #6
bae14
9
Thanks so much for your help! I believe I can get beyond this now. Have a good day.
May 29 '07 #7
NeoPa
32,556 Expert Mod 16PB
No problem.
Good luck with you project :)
May 29 '07 #8

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

Similar topics

5
by: Gord | last post by:
Hello, If you set the flag for an overwrite prompt using the 'Save' common dialog, how do you read the response when the user clicks the Yes or No in the 'overwrite' message box? Everything...
6
by: Paul Deverson | last post by:
I'm a newbie to MySQL and am really confused about when I should be using the Command Line Client and when the DOS prompt. I'm using Windows XP and I've just installed MySQL 4.1.10. I can use...
0
by: Chris Powell | last post by:
I am using Excel/Access 2000 and have two large Excel files (25,000 rows each) that I wish to create linked tables in Access rather than importing into Access. The two source Excel files change...
3
by: Tom van Stiphout | last post by:
We secured an Access MDB for a client, using the Access 2000 (or above - still trying to find that out) security wizard. I trust the developer who did this, and the screendumps of the process don't...
1
by: jodyblau | last post by:
I applogize for posting this a second time (I posted in the access-multiuser group as well), but this group seems to respond more rapidly, and I have been trying to figure this out for what seems...
5
by: melickas | last post by:
We designed a custom application using Office Developer Tools '97 which included a Run-time version of Access--- so it would not matter if our customer even had any version of Access on their...
2
by: kmarchiony | last post by:
Hi anyone! I am working to translate an Excel macro into Access and I'm having little luck with a couple lines of code. I can't figure out how to prompt the user to select a file (not to past a...
4
by: ARC | last post by:
Hello all, I didn't use to have this problem in Access 97, but in 2007 (and maybe other versions of access after 97), if you have a form that has a subform, and you click the close button, you...
0
by: =?Utf-8?B?TW9uaXF1ZQ==?= | last post by:
I just reinstalled IIS as I worked with wamp before and yet I didn't find out how to have a php and a asp server working the same time on a computer. (I had to uninstall the IIS to get wamp at...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.