473,811 Members | 2,685 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prompt a user for a file in Access

9 New Member
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.Fil eDialog 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 4627
NeoPa
32,579 Recognized Expert Moderator MVP
Try using (msoFileDialogF olderPicker) on your line number 7.
Expand|Select|Wrap|Line Numbers
  1. Set myDialog = Application.FileDialog(msoFileDialogFolderPicker)
May 25 '07 #2
NeoPa
32,579 Recognized Expert Moderator MVP
Try using (msoFileDialogF olderPicker) 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 New Member
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 New Member
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,579 Recognized Expert Moderator MVP
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 New Member
Thanks so much for your help! I believe I can get beyond this now. Have a good day.
May 29 '07 #7
NeoPa
32,579 Recognized Expert Moderator MVP
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
7496
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 I've read explains about setting the flag to bring up the overwrite prompt message box, but there's no explanation on how to read the response to it. It appears that clicking the Yes option doesn't actually overwrite the old file, so I assume I'm...
6
14600
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 the Command Line Client to logon as 'root'. It prompts me for a password and then I can create databases, etc. from the mysql prompt. However, if I wanted to logon as a different user, I'm not sure how to do it.
0
8686
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 frequently, so I want to: A) prompt the user, using a custom form, for the specific Excel files to be linked; B) create the links dynamically; C) insert the linked tables into a select query grid and include the SQL statement in the VBA...
3
1682
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 give any indication he missed a step, or got an error, etc. On several machines in our office, if you try to open the database without the special system.mdw, you correctly get an error "You do not have the necessary permissions...". With that...
1
4710
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 like forever. I have the Access 2002 Developer's Handbook, and I am trying to learn from the example provided in Chapter 2, but I am running into the following problem. I set an admin password and a username and password on the backend,
5
2581
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 computer. The application ran without problems on our customer's computer for 2-3 years. Then our customer bought a new computer and we had to reinstall the application. Everything was ok for approximately 6 months until our customer was "cleaning up"...
2
35819
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 path and filename) but to actually browse for a file :) Here is the Excel code I already have: Dim TxtName As String TxtName = Application.GetOpenFilename("TextFiles (*.txt), *.txt", , "Select The file you wish to update:") I'm also hoping to...
4
7840
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 always get the following dialog: "Save changes to the following objects?" I tried putting a saverecord command prior to the close, but that had no affect. I have found a work around, but maybe I am making this too
0
1740
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 work). But my question now is only about asp. Everything works in asp only that there comes a popup that ask for username and password. I searched what could be meant and saw you use the terminology "IUSR_COMUTERNAME and IWAM_COMPUTERNAME". I...
0
9727
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10386
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10398
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3017
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.