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) -
Private Sub CB_RunQueryPrintReport_Click()
-
Dim stDocName As String
-
Dim Filename As String
-
Dim i As Integer
-
Dim test As String
-
Dim MyDB As DAO.Database
-
Dim REQ As DAO.Recordset
-
Dim UDI As DAO.Recordset2
-
-
Set MyDB = DBEngine.Workspaces(0).Databases(0)
-
Set REQ = MyDB.OpenRecordset("Tbl_REQData", DB_OPEN_TABLE)
-
Set UDI = MyDB.OpenRecordset("Tbl_UDIData", DB_OPEN_TABLE)
-
-
-
DoCmd.Hourglass True
-
DoCmd.SetWarnings False
-
-
'Set tables before exporting
-
DoCmd.OpenQuery "Qry_FindPanelParts"
-
DoCmd.OpenQuery "Qry_PanelsToCut"
-
DoCmd.OpenQuery "Qry_PanelsToCutAddOn"
-
DoCmd.OpenQuery "Qry_PanelsToCutAddOn2"
-
DoCmd.OpenQuery "Qry_PanelsToCutAddOn3"
-
DoCmd.OpenQuery "Qry_PanelsToCutAddOn4"
-
'DoCmd.OpenQuery "Qry_ChrParts_Req"
-
'DoCmd.OpenQuery "Qry_ChrParts_UDI"
-
-
-
Filename = "C:Cherry.csv"
-
Open Fileopen For Output As #1
-
REQ.MoveFirst
-
UDI.MoveFirst
-
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")
-
Print #1, UDI.rowt, ",", UDI.fld2, ",", UDI.SEQ, ",", UDI.fld4, ",", UDI.fld5, ",", UDI.Len, ",", UDI.WID, ",", UDI.fld8
-
Close #1
-
-
DoCmd.Hourglass False
-
DoCmd.SetWarnings True
-
-
-
End Sub
-
I’m sure someone will be able answer this in their sleep.
I the file is already created and is blank.
Thanks in advance.
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 : - 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.
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.
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.
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 : - 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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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:
...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |