473,795 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Verify file name exist from table field

52 New Member
Is it possible and if so, how?

Would like to have code to verify that a file name in a same directory matches with the file name in a table/ field. If it matches then run the rest of the code, if not prompt with error.

Can someone give me some pointer how this should be written

Thanks for any help you could offer
Jun 16 '10 #1
4 2354
timleonard
52 New Member
Found something that may work.

Expand|Select|Wrap|Line Numbers
  1. Dim fso
  2. Dim file As String
  3. file = strXLFile   ' change to match the file w/Path
  4. Set fso = CreateObject("Scripting.FileSystemObject")
  5. If Not fso.FileExists(file) Then
  6.     MsgBox file & " was not located.", vbInformation, "File Not Found"
  7. Else
  8.     MsgBox file & " has been located.", vbInformation, "File Found"
  9. End If
  10.  
Still open to any other suggestions
Jun 17 '10 #2
NeoPa
32,579 Recognized Expert Moderator MVP
I would start with the field value in the table. The current folder can be found from CurrentProject. FullName if you remove the name part. Add the value from the field to this and use the Dir() function to determine if it does indeed exist.

Using FileSystemObjec t is an alternative, but I would say it's more complicated and requires a library reference which is less standard than the VBA one which is common to all projects.
Jun 17 '10 #3
timleonard
52 New Member
@NeoPa
Excellent Suggestion...
I am trying the following and it works

Expand|Select|Wrap|Line Numbers
  1.  
  2. If Len(Dir(strXLFile)) = 0 Then
  3.         MsgBox "Could not find " & strXLFileName & ", Check the " & strCurrentDir & " Folder and the Paths Setup to be sure the file names match.", vbInformation, "File Not Found"
  4.         GoTo Exit_Sub
  5.     Else
  6.        'Continue through the code
  7.     End If
  8.  
Jun 18 '10 #4
NeoPa
32,579 Recognized Expert Moderator MVP
Glad you got it working Tim. I'd suggest replacing line #5 (Else) with line #7 (End If), but that's just semantics.
Jun 18 '10 #5

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

Similar topics

10
2765
by: MLH | last post by:
I have an A97 table with a Yes/No field named TowJob and a form bound to that table. The TowJob control on the form is bound to the same field. It is an option group with Yes and No bttns valued at -1 and 0 respectively. Unless I specifically set the table field's defaultvalue to Null, the form comes up with an automatic value of 0 in the control? The control has NO default value property setting. Why is that?
2
7990
by: Greg Strong | last post by:
Hello All, Is it possible to change table field lookup properties in code? I've been able to change other field properties in code, however so far no luck with field lookup properties. What I've done for test purposes is use a text input file for the table field lookup properties. I thought that I'd start first by just changing the 'Display Control' property. Thanks to Allen Browne for some ideals per...
1
1380
by: Gaetan | last post by:
I have a web application where the user can type the name of a file name in a field. I want to make sure the syntax of that filename is valid before using it. I browsed the methods in various .Net 2.0 framework assemblies and there does not seem to be any to validate the syntax of a string representing a filename. Is there a method I can use to validate the syntax of a NTFS file name? regards,
18
2339
by: walterbyrd | last post by:
I am trying to develop an app where: the same file, in the same place, will be uploaded, and then processed. Everything I can find about uploading a file, uses a form that requires the user to either manually enter the path and file name, or to browse for the file. I do not want that. Ideally, I want the user to click on a link, and the server side php app does the rest. Again, the file always has the same name, and is in the same place....
4
6592
by: bryanp10 | last post by:
How do I do a client-side check to see that a file exists before attempting to upload it? I am trying to avoid the "Access denied" error I get on form submission if an invalid name is entered in the textbox. This page does it beautifully: http://msconline.maconstate.edu/tutorials/ASPNET2/ASPNET09/aspnet09-11.aspx But how???
4
4694
by: M6C | last post by:
Hello, I'm trying to import a Xml file in a table. It's working find, but when the data are inserted, my trigger on this table doesn't work ? I put my code below. Best regards Thank's
185
7137
by: jacob navia | last post by:
Hi We are rewriting the libc for the 64 bit version of lcc-win and we have added a new field in the FILE structure: char *FileName; fopen() will save the file name and an accessor function will return the file name given a FILE *. Questions: What would be the best name for this function?
3
2997
by: adiel_g | last post by:
Hello everyone, I am trying to move a field name to a variable in vb.net. For example, first I retrieve the record from the database and save its value: .... userGroup = ds.Tables("Default").Rows(x).Item("UserGroupAccess").ToString 'retrive access value from dataset ....
6
26333
by: provor | last post by:
Hello, I have the following code that I am using when a user presses a button to import an excel file into a table. The code is hard coded to point to the correct table. This works great for this one table. My problem is I have two buttons I want to use this code for for the two buttons would put the data in different tables. I have tried copying and changing a few things and nothing will work for me. The code is set up in a module and then I...
2
5333
by: timleonard | last post by:
How do you reference the Table:Field to use in a file path? I have been trying the code below I would like to reference a Tablel:Field to use in the path instead of hard coding the file name, as the name of the file will change between the branches that use it Dim strQryName As String, strXLFile As String, strXLFileName As String strDB = CurrentDb.Name strCurrentDir = Left(strDB, Len(strDB) - Len(Dir(strDB))) ...
0
9673
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
9522
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,...
1
10165
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
10002
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9044
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
6783
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
5437
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...
1
4113
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
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.