473,406 Members | 2,705 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,406 software developers and data experts.

Writing out a CSV file getting Run-time error ‘75’: Path/File access error

49
Using Access 2010

I need to write a CSV file where the number of fields on each record is not the same, requirement of the program we are feeding.

Below is the code I am having I am getting the error: Run-time error 75: Path/File access error.

Error is happening at “Open fileopen for Output as #1” (line 30)

Expand|Select|Wrap|Line Numbers
  1. Private Sub CB_RunQueryPrintReport_Click()
  2. Dim stDocName As String
  3. Dim Filename As String
  4. Dim i As Integer
  5. Dim test As String
  6. Dim MyDB As DAO.Database
  7. Dim REQ As DAO.Recordset
  8. Dim UDI As DAO.Recordset2
  9.  
  10. Set MyDB = DBEngine.Workspaces(0).Databases(0)
  11. Set REQ = MyDB.OpenRecordset("Tbl_REQData", DB_OPEN_TABLE)
  12. Set UDI = MyDB.OpenRecordset("Tbl_UDIData", DB_OPEN_TABLE)
  13.  
  14.  
  15. DoCmd.Hourglass True
  16. DoCmd.SetWarnings False
  17.  
  18. 'Set tables before exporting
  19. DoCmd.OpenQuery "Qry_FindPanelParts"
  20. DoCmd.OpenQuery "Qry_PanelsToCut"
  21. DoCmd.OpenQuery "Qry_PanelsToCutAddOn"
  22. DoCmd.OpenQuery "Qry_PanelsToCutAddOn2"
  23. DoCmd.OpenQuery "Qry_PanelsToCutAddOn3"
  24. DoCmd.OpenQuery "Qry_PanelsToCutAddOn4"
  25. 'DoCmd.OpenQuery "Qry_ChrParts_Req"
  26. 'DoCmd.OpenQuery "Qry_ChrParts_UDI"
  27.  
  28.  
  29. Filename = "C:Cherry.csv"
  30. Open Fileopen For Output As #1
  31. REQ.MoveFirst
  32. UDI.MoveFirst
  33.     Print #1, REQ("rowt"), ",", REQ("fld2"), ",", REQ("SEQ"), ",", REQ("part"), ",", REQ("fld5"), ",", REQ("Len"), ",", REQ("WID"), ",", REQ("fld8"), ",", REQ("fld9"), ","; REQ("fld10"), ","; REQ("fld11"), ","; REQ("fld12"), ",", REQ("Fld13")
  34.     Print #1, UDI.rowt, ",", UDI.fld2, ",", UDI.SEQ, ",", UDI.fld4, ",", UDI.fld5, ",", UDI.Len, ",", UDI.WID, ",", UDI.fld8
  35. Close #1
  36.  
  37. DoCmd.Hourglass False
  38. DoCmd.SetWarnings True
  39.  
  40.  
  41. End Sub
  42.  
I’m sure someone will be able answer this in their sleep.

I the file is already created and is blank.

Thanks in advance.
Dec 4 '12 #1

✓ answered by NeoPa

Andy, let me congratulate you first on a much better question :-)

I suspect you have an issue with Require Variable Declaration, as it appears line #30 has an error trying to reference a variable that neither exists nor has been set - Fileopen. I suspect you intended to use :
Expand|Select|Wrap|Line Numbers
  1. Open Filename For Output As #1
NB. Don't forget the earlier advice to specify the path of the file fully and correctly. "C:Cherry.csv" refers to a file whose name is "Cherry.csv" and which is found in the C drives currently selected folder. As this hasn't been set in the code it is rather pot-luck where it will be looking for it.

PS. It is always recommended to use a value returned by FreeFile() rather than the explicit value 1.

4 4508
zmbd
5,501 Expert Mod 4TB
Fix may depend on the operating system (XP, Vista, etc...)
This is normally due to lack of privilage to read/write/modify files in the directroy.
Dec 4 '12 #2
Rabbit
12,516 Expert Mod 8TB
I don't know if this is a typo but
C:Cherry.csv
needs to be
C:\Cherry.csv or C:\\Cherry.csv
depending on if the backslash needs to be escaped.
Dec 4 '12 #3
zmbd
5,501 Expert Mod 4TB
Thnx Rabbit, missed that.

Your first should work as that what I have used in the past for path names.

In anycase, most I.T. block writing to the root directory of the boot drive (typically "C:\") since WinNT and since Windows Vista the default is to prevent anything accept system from writing to the root drive.

So if the fix to the path doesn't work you'll still need to check into the security settings.
Dec 4 '12 #4
NeoPa
32,556 Expert Mod 16PB
Andy, let me congratulate you first on a much better question :-)

I suspect you have an issue with Require Variable Declaration, as it appears line #30 has an error trying to reference a variable that neither exists nor has been set - Fileopen. I suspect you intended to use :
Expand|Select|Wrap|Line Numbers
  1. Open Filename For Output As #1
NB. Don't forget the earlier advice to specify the path of the file fully and correctly. "C:Cherry.csv" refers to a file whose name is "Cherry.csv" and which is found in the C drives currently selected folder. As this hasn't been set in the code it is rather pot-luck where it will be looking for it.

PS. It is always recommended to use a value returned by FreeFile() rather than the explicit value 1.
Dec 5 '12 #5

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

Similar topics

6
by: Jay donnell | last post by:
I have a short multi-threaded script that checks web images to make sure they are still there. I get a segmentation fault everytime I run it and I can't figure out why. Writing threaded scripts is...
3
by: Tommo | last post by:
Hello All, I am a still learning so be easy on me. I am trying to get some code to work that is using JS and Perl/CGI, I am using AS Perl and an Apache Server on XP as the webserver. Can anyone...
3
by: MJR | last post by:
Hi all, Probably a simple question but I just cannot seem to find the answer. I am trying to get the folder where the application runs from (i.e. where the .exe is) . Everything I have tried...
4
by: serge | last post by:
Lately I did a mass update on all our scripts and added dbo. in front of all tables and other objects. There is a function that returns a table and the function is I think 300 lines. There are a...
3
by: Titanus | last post by:
Hello all, I am running MS on a Dell PC and I want to get started writing C++ code. Only thing I can find about how to get started is to find MS SQL Server. Okay, so once I find that, how do I...
0
by: John.NET | last post by:
Hi, I'm writing a web service where one method will launch another .NET program under a specified user's account. It launches fine as the NT AUTHORITY\NETWORK SERVICE user when I dont specify a...
7
by: Lee Crabtree | last post by:
I remember when I was first getting into .NET Forms programming that there was a rather emphatic rule about not constructing a form before calling Application.Run with it. So this: ...
22
by: JoeC | last post by:
I am working on another game project and it is comming along. It is an improvment over a previous version I wrote. I am trying to write better programs and often wonder how to get better at...
7
by: buzzluck68 | last post by:
Hello, I have an in house application that we developed, but everyone who needs to use the program are not allowed to be local admins on their PCs. I was wondering if there was a way to code...
4
by: mayaanu | last post by:
I have developed a GUI based application in C# for communicating with a 16 bit littleendian microcontroller device .the device has a serial port interface. 1.my appplication opens a COM port on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
0
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,...

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.