VBA Code Unable To Create Text File on C:\ Drive In Acc2007

I have a VBA Code that works in Acc2000 and Acc2003 on XP Pro OS Sp3.  I was 
tesing the same code with Acc2007 with Win 7 Pro (64-bits).  My Acc2003 has 
Sp3 and my Acc2007 has Sp2.

This is the VBA Code that I used:

    Dim FullPath As String
    Dim QueryName As String
    Dim filename As Variant
    
    filename = Forms![Video Export]![Text22]
    FullPath = "c:\" & Trim(filename) & ".txt"
    AvidQueryName = "OutputToVideo"
    DoCmd.TransferText acExportDelim, "Comma Delimited Spec 2007", _   
           QueryName, FullPath, False


I noticed the following:  
     1)      Running with Acc2003 with Win 7 Pro (64-bits), it works.  Text 
file was    
              created in the c:\ drive.

     2)      Running with Acc2007 with Win 7 Pro (64-bits), it gives me the 
following 
              error:    "Run-time error '3051'   The Microsoft Office Access 
data base
              engine cannot open or write to the file.  It is already opened 
exclusively 
              by another user, or you need permission to view and write its 
data."

              When I changed the "FullPath" to write the text file in side 
an existing 
              folder - it works !    This was the change:

              FullPath = "c:\Test\" & Trim(filename) & ".txt"

The Win 7 Pro (64-bits) is the same for both of the about test.

It seems that Acc 2007 is not allowing me to write or create a text file in 
the c:\ drive.    

Can someone help me here ??   What would I need to allow this to happen ???

Thank You,

G
0
Utf
1/25/2010 4:50:01 PM
access.modulesdaovba 1670 articles. 0 followers. Follow

10 Replies
1028 Views

Similar Articles

[PageSpeed] 41

hi Gary,

On 25.01.2010 17:50, Gary wrote:
> It seems that Acc 2007 is not allowing me to write or create a text file in
> the c:\ drive.
>
> Can someone help me here ??   What would I need to allow this to happen ???
An ordinary user has not the NTFS permissions to do that since Windows 
2000. Use one of your known folders instead of this:

http://msdn.microsoft.com/en-us/library/bb776911(VS.85).aspx
http://msdn.microsoft.com/en-us/library/bb762584(VS.85).aspx

E.g. the desktop or the documents folder.


mfG
--> stefan <--
0
Stefan
1/25/2010 4:57:19 PM
You used the word "ordinary user", how about one with "admin" rights ???

Gary




"Stefan Hoffmann" wrote:

> hi Gary,
> 
> On 25.01.2010 17:50, Gary wrote:
> > It seems that Acc 2007 is not allowing me to write or create a text file in
> > the c:\ drive.
> >
> > Can someone help me here ??   What would I need to allow this to happen ???
> An ordinary user has not the NTFS permissions to do that since Windows 
> 2000. Use one of your known folders instead of this:
> 
> http://msdn.microsoft.com/en-us/library/bb776911(VS.85).aspx
> http://msdn.microsoft.com/en-us/library/bb762584(VS.85).aspx
> 
> E.g. the desktop or the documents folder.
> 
> 
> mfG
> --> stefan <--
> .
> 
0
Utf
1/25/2010 9:16:19 PM
You have a variable "AvidQueryName" declared somewhere(?) and you have a
variable "QueryName". Which is the correct variable in the DoCmd for
"QueryName"?

It is also possible that you may having an existing file (same path and file
name) and may have prevented you from editing the file or replacing the file.

Gary wrote:
>This is the VBA Code that I used:
>    Dim FullPath As String
>    Dim QueryName As String
>    Dim filename As Variant
>    
>    filename = Forms![Video Export]![Text22]
>    FullPath = "c:\" & Trim(filename) & ".txt"
>    AvidQueryName = "OutputToVideo"
>    DoCmd.TransferText acExportDelim, "Comma Delimited Spec 2007", _   
>           QueryName, FullPath, False
snip.......

-- 
Please Rate the posting if helps you.

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201001/1

0
AccessVandal
1/26/2010 1:18:13 AM

"AccessVandal via AccessMonster.com" wrote:

> You have a variable "AvidQueryName" declared somewhere(?) and you have a
> variable "QueryName". Which is the correct variable in the DoCmd for
> "QueryName"?
> 
> It is also possible that you may having an existing file (same path and file
> name) and may have prevented you from editing the file or replacing the file.
> 
> Gary wrote:
> >This is the VBA Code that I used:
> >    Dim FullPath As String
> >    Dim QueryName As String
> >    Dim filename As Variant
> >    
> >    filename = Forms![Video Export]![Text22]
> >    FullPath = "c:\" & Trim(filename) & ".txt"
> >    AvidQueryName = "OutputToVideo"
> >    DoCmd.TransferText acExportDelim, "Comma Delimited Spec 2007", _   
> >           QueryName, FullPath, False
> snip.......
> 
> -- 
> Please Rate the posting if helps you.
> 
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201001/1
> 
> .
> 
0
Utf
1/26/2010 5:47:01 AM
No duplicates.  I checked that for sure !!

Gary



"AccessVandal via AccessMonster.com" wrote:

> You have a variable "AvidQueryName" declared somewhere(?) and you have a
> variable "QueryName". Which is the correct variable in the DoCmd for
> "QueryName"?
> 
> It is also possible that you may having an existing file (same path and file
> name) and may have prevented you from editing the file or replacing the file.
> 
> Gary wrote:
> >This is the VBA Code that I used:
> >    Dim FullPath As String
> >    Dim QueryName As String
> >    Dim filename As Variant
> >    
> >    filename = Forms![Video Export]![Text22]
> >    FullPath = "c:\" & Trim(filename) & ".txt"
> >    AvidQueryName = "OutputToVideo"
> >    DoCmd.TransferText acExportDelim, "Comma Delimited Spec 2007", _   
> >           QueryName, FullPath, False
> snip.......
> 
> -- 
> Please Rate the posting if helps you.
> 
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201001/1
> 
> .
> 
0
Utf
1/26/2010 5:48:01 AM
So.........what about the "QueryName"?

Gary wrote:
>No duplicates.  I checked that for sure !!
>
>Gary

-- 
Please Rate the posting if helps you.

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201001/1

0
AccessVandal
1/26/2010 8:54:56 AM
Forgot to add.

filename = Forms![Video Export]![Text22]
   FullPath = "c:\" & Trim(filename) & ".txt"

"Comma Delimited Spec 2007"

The DoCmd will always name the file as "Comma Delimited Spec 2007". But your
variable is not in the DoCmd as it is surposed to be "filename". So are you
certain?

Gary wrote:
>No duplicates.  I checked that for sure !!
>
>Gary

-- 
Please Rate the posting if helps you.

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201001/1

0
AccessVandal
1/26/2010 9:03:25 AM
hi Gary,

On 25.01.2010 22:16, Gary wrote:
> You used the word "ordinary user", how about one with "admin" rights ???
This dependes on the Windows version and the installation type. At least 
as Admin you can give you the permissions to do so.

mfG
--> stefan <--
0
Stefan
1/26/2010 10:00:59 AM
Yes.   Remember that the same program works on Win 7 Pro (64-bits) with 
Acc2003.   I tried that.  

I then ran it in a virtual machine with the same Win 7 Pro (64-bits) with 
Acc 2007 and I get this issue.   If I change the Fullpath to an existing 
folder and not dirrectly to the c:\ drive, it works !

Do you think I lack permission in the virtual machine ??   How do I check 
the permission in Win 7 ??


Thank You,

Gary

"AccessVandal via AccessMonster.com" wrote:

> Forgot to add.
> 
> filename = Forms![Video Export]![Text22]
>    FullPath = "c:\" & Trim(filename) & ".txt"
> 
> "Comma Delimited Spec 2007"
> 
> The DoCmd will always name the file as "Comma Delimited Spec 2007". But your
> variable is not in the DoCmd as it is surposed to be "filename". So are you
> certain?
> 
> Gary wrote:
> >No duplicates.  I checked that for sure !!
> >
> >Gary
> 
> -- 
> Please Rate the posting if helps you.
> 
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201001/1
> 
> .
> 
0
Utf
1/26/2010 4:22:08 PM
I'm not using Win7, so I'm not sure about the newer security setup. Seems
like a lack of permissions to me. Since you're using VM with Win7, it might
be the reason. Have you check your VM forums yet?

Do you know that Access 2007 need Trusted Location? Did you include the file
path for that Trusted Location? It's worth a try to see if that's the case.

Gary wrote:
>Yes.   Remember that the same program works on Win 7 Pro (64-bits) with 
>Acc2003.   I tried that.  
>
>I then ran it in a virtual machine with the same Win 7 Pro (64-bits) with 
>Acc 2007 and I get this issue.   If I change the Fullpath to an existing 
>folder and not dirrectly to the c:\ drive, it works !
>
>Do you think I lack permission in the virtual machine ??   How do I check 
>the permission in Win 7 ??
>
>Thank You,
>
>Gary

-- 
Please Rate the posting if helps you.

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201001/1

0
AccessVandal
1/27/2010 12:49:48 AM
Reply:

Similar Artilces:

How do I get excel to accept (c) as text and not change to copyri.
How do I enter the text (c) in Excel without having it changed into the copyright symbol? Hi Daffyd, Try: Tools | Autocorrect | Select (c) | Delete | OK --- Regards, Norman "daffyd" <daffyd@discussions.microsoft.com> wrote in message news:8CCC3C1A-6F19-4F62-B934-8A71F236A4FD@microsoft.com... > How do I enter the text (c) in Excel without having it changed into the > copyright symbol? Go into the Tools Menu. Look for AutoCorrect. In the bottom half of the AutoCorrect Tab, look at the list for Replace text as you type. Delete the entry for (c). tj "da...

ANN: C# Online.NET Spanish Project
FOR IMMEDIATE RELEASE First Spanish-Language, Wiki-based, Online C# and .NET Reference at C# Online.NET Dallas, TX � A new concept in online references for Microsoft .NET programming languages is being pioneered by C# Online.NET�a new wiki-based, online C# and .NET reference. C# Online.NET offers documentation, tutorials, and C# source code examples for .NET languages beginning with the C# language. "Compared to Java," says Will Wagers, founder of C# Online.NET, "there is a dearth of online C# help." C# Online.NET is enlisting the aid of volunteer contributors to write ...

How to create a ledger sheet
Hello. I have a database with the following tables:Customers, Orders, and PaymentsThe Customers table has a one-to-many relationship with the Orderstable. The Customers table also has a one-to-many relationship withthe Payments table.I am trying to create what I think is commonly called a ledger sheet.This sheet simply shows the dollar amount of every order that anindividual customer has placed (debits) and every payment that thecustomer has made (credits). It also shows a running balance. Entriesare shown in chronilogical order.I am having trouble creating a report that would draw debits from...

How can I open a file saved in Pub 2000 version 6 in Pub 2000 ver.
The file is saved in Publisher 2000 v6 and I am trying to open it with Publisher 2000 v9. can this be done? Hi LaTrice (LaTrice @discussions.microsoft.com), in the newsgroups you posted: || The file is saved in Publisher 2000 v6 and I am trying to open it || with Publisher 2000 v9. can this be done? No. There is no such thing as Publisher 2000 v9, nor is there a version 9 of Publisher, yet. Verify the version of Publisher that you have, and also verify the version of Publisher that you received the file from then post back. -- Brian Kvalheim Microsoft Publisher MVP http://www.publi...

Stagger X-axis text
In 1-2-3 I could stagger the text in the X-axis. In Excel it seems that I can only rotate the text to 90 degrees. Is there a way to stagger and leave horizontal? Specifically, I have all the provinces (or 10 of them) across the axis and they take up room when spelt out (no abbreviations allowed). I would rather the first, third, fifth ... etc. be higher and the second, fourth etc. be lower to allow the chart to be narrower and still read the text clearly. Cheers, Deborah >-----Original Message----- >In 1-2-3 I could stagger the text in the X-axis. In Excel it seems Deborah I would...

Numbers in a text field-can I add them up?
Hi everyone! Using A02 on XP. I have a table of data with survey response fields that contain a 0,1,2,3,4 or 5. However, the fields are formatted as text, not numbers. I need to add up certain blocks (Items 1-6, Items 7-23, etc.) and then do some averaging. I cannot change the field types from text. Must I append to a new table or can I do something right in my query? I've got one field in my query like this: ES: [Item1]+[Item2]+[Item3]+[Item4]+[Item5]+[Item6] My result is: 553453 or 554444, etc. I want: 25 or 22, etc. I would really appreciate any help or advice. Thanks...

Need help getting this code to compile under VS.NET 2003 (compiles under VS6.0).
I'm tasked with converting a LARGE project from VS6.0 to VS.NET 2003. Here is a VERY scaled down version of an error I'm getting. I must be getting rusty, but the way to get around this compiler error is just not coming to me. If you need to compile this, just create a Win32 console app and specify to add support for MFC, then copy this code into the cpp file and press compile. class CLogItem : public CObject { protected: virtual BOOL CheckConflict(CLogItem* pItem) const; }; struct MapEntry; //forward declaration.. typedef CArray<MapEntry, MapEntry&> CMapEntryArray;...

Just installed new hard drive
I just installed a new hard drive and used the drive's utility program to copy everything from my old drive to the new one. Now Outlook isn't going out to my ISP's server and getting my new messages, and when I send a message I get the "no transport provider available" error. (My connection's just fine.) I looked online for some help. One recommendation was to delete the Personal Folder and create a new one. I did that, but then all the messages I had disappeared and it freaked me out so I didn't want to mess with anything else. How can I make it work ...

how to query my web site from VBA and return a value to VBA
Hello All, From VBA I would like send a value to my web site, and have it return a value. I've learned how to use FollowHyperlink to send a value to an ASP script, but how can the ASP script send a value back to VBA?? Thanks, Brian Austin, TX You can use xmlhttp to make a request to your web page: '********************************************************* Sub Tester() MsgBox WebResponse("http://www.mydomain.com/myactualpage.asp? info=3Dblah") End Sub Private Function WebResponse(sURL As String) As String Dim XmlHttpRequest As Object Se...

How do I create a bookfold document in Word 2007?
I am new to Word 2007. How do I create a document in booklet form? Thanks I'm sure you'll get better answers in an MSWord forum. dadolim wrote: > > I am new to Word 2007. How do I create a document in booklet form? Thanks -- Dave Peterson ...

How to use structured reference (ListColumns) in VBA
I want to do something simple...loop through a range retrieving values one at time and taking action on that value. This range is an Excel 2007 table column. Easy enough...BUT I want to use structured references to a table column by NAME, not numbers. I don't want to define new names, just use the table column headings. I've found ways of doing it with quotes, but that's not structured....the names in quotes do not change if the table heading is changed by the user. The formulas change if the table column heading is changed, but I want it to change in VBA to...

object not being created
hello, I created a dialog based application.I pop up a modal dialog from the menu created in my application.Class midialog is associated with this dialog resource.By mistake i created an obj of this class in the menu handler as shown in code below. OnMenu()//handler in my application dialog class.i.e.main dialog { midialog m_d; m_d.DoModal();//creating my modal dialog } after couple of daysi realized that i wanted the obj not inside the handler but in the class CMainDlg(class of the main dialog).So i removed above code and tried to declare a variable of type midialog m_d(again,s...

automatically naming files for savingb
Hi, for delivery notes i would like excel to look in the relative directory for a given customer, ie if C4 contains superspecs, files relating to this account would be in c:\work\superspecs\ files are named superspecsdel0001,superspecsdel0002.......etc superspecsinv0001...etc for delivery notes and invoices. what i would like is a line (or more) to add to a macro which will look in the appropriate directory, add 1 to the last four digits of the last file, enter this number into a cell on the sheet and save the new file with the appropriate name, then close the file. is this possible, or alte...

why do changes only save locally on networked excel file?
why do changes only save locally on networked excel file? ...

VISIO 2007 -Text direction
can some one tell me how to change text to be type in vertically. Under tools, options there is no regional tab or under format text the change text direction command does not work. "kgbrat" <kgbrat@discussions.microsoft.com> wrote in message news:2DBF18B5-E1C8-4493-8BEF-F7D4C1538781@microsoft.com... > can some one tell me how to change text to be type in vertically. Under > tools, options there is no regional tab or under format text the change > text > direction command does not work. You can use the Text Tool (The A with an circular arrow around it) and gr...

Help ! formatting data to text
I am creating data in an Excel spreadsheet. I then want to get that data into a simple text email. I have some problems and questions... 1) how do I get the columns of data to line up evenly when I copy the data to email text ? Keep in mind I need to be in simple text format, not HTML or rich text. Every time I do this, all columns become chaos and are unreadable. 2) Is there a simple way to automate the creation of an email from an excel file ? this is less important to me. Thanks in advance WxMachine #1. I think it may have to do with what email client you use, too. I copy and ...

Printing Word and excel documents via excel vba
I have a document that has some Excel and some word content i would like to use excel vba to print both a page from word and then a page from excel. I know how to select and open the word document, however i cant find any code to print page X from word. basically i need to: print page 1 of c:\xx\document1.doc print page1 of sheet1 of c:\yy\excelwkbk1.xls print page 2 of c:\xx\document1.doc print page2 of sheet1 of c:\yy\excelwkbk1.xls and so on it will require moving between word and excel - the excel bit i get, but getting back to excel from word, and printing out in word is slightly more...

Can't Stop External Hard Drive
I have a Western Digital 250 gb external hard drive connected via USB port. I am also running Outlook 2007, which I believe has a function searchindexer.exe that searches all my drives to index the files on them. I want to be able to unplug the drive without first turning off my computer. But I get messages saying that the drive can't be stopped. It used to be that if I stopped searchindexer.exe, I could stop the drive. But that's stopped working. Here are two questions: 1. What is preventing me from stopping the drive?; 2. What is the worst that can happe...

Unknown error code
Hi, I'm trying to set up email in outlook 2007. After I put in all the information and click on "test account settings", I'm getting an error message. I mean, in the task tab, the "log onto incoming mail server (POP3), the status is completed" but on "send test email message, the status is Failed. and the error message is giving is "an unknown error code: 0x80040607 Does anybody knows out to fix this? Have you been able to send mail out before using that account, possibly with another mail client? "DM" <DM@discussions.microsoft.com> ...

Pay code update with Integration Manager
I am trying to do a Pay Code update for all employees using Integration Manager using the General Payroll Update. I am able to get the standard Pay Codes to update, but cannot seem to get the "Based On" Pay Codes to update. When I log into GP and view the Employee Maintenance and Go To Pay Codes, I see the standard update. However the Based On Pay Codes remain the old rates unless I select select the Pay Code and simply click Ok. Then the update automatically is brought in. How can I get these updates to take without having to visit each of the Based On Pay Codes and sele...

Macro Security, Password Recovery & VB Code execution
I have found that if I set my macro security to high, VB code within (non-trusted) excel sheets do not execute... a microsoft security feature that ostensibly prevents non- trusted users from running VB The questions I have are : Is there a way to guarantee VB macro-execution using digital certificates or what-have-you ? Is there a way to detect, either within excel (well, not possible, it seems) or from outside, that the combo of users macro-security settings and signature status of a perticular excel file, WILL prevent VB from executing, if the file is attempted to opened ? ...

Outlook should keep files in the clipboard after closing a window
When you open a message (in a new window) in Outlook 2007, and copy one or more files contained in this message, and then close the window, the file is not kept in the clipboard. I have to copy the file and paste it before closing the window. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I ...

Deleted file in Outlook
I accidentaly deleted a folder in Outlook 2003 and am wondering if it possible to retreive it. Thank you, Karl youthminman@yahoo.com <youthminman@yahoo.com> wrote: > I accidentaly deleted a folder in Outlook 2003 and am wondering if it > possible to retreive it. Unless you permanently deleted it (i.e., held down Shift when pressing Delete), it will be in your Deleted items folder, unless you've emptied that folder. If you have emptied it, other suggestions depend on knowing what data store you're using (PST or Exchange mailbox). -- Brian Tillman ...

red recovery drive folder
So I got a virus on my computer a month ago and I had a friend from geek squad come over and restart it with a recovery disk that Dell had sent me (I have a dell) after it was restored and the virus was gone my recovery folder was red and switched to my C: drive, and my os is now D: drive. When I asked him about the recovery drive being red he just told me that "its a good thing" but now when I go to download things for school onto my computer they wont stay, they download but stop right before its finished and I can't find it anywhere. I really need my computer properl...

Text in column causing SUMPRODUCT error
Greegings. I have a SUMPRODUCT formula that is having errors when one of the columns has text instead of a NULL or a number. If I delete the text cells in that column it works as desired. I'll give a simple example. Suppose I have the following in A1:B6.... a 1 a 2 a abc b 1 b 1 a 2 And I need this... =SUMPRODUCT(($A$1:$A$6="a")*($B$1:$B$6)) It errors out until I delete the "abc" in cell B3, then it works as desired. I tried to replace the "abc" with a 0 by trying this... =IF(ISNUMBER(B3)=FALSE,0,B3) And it works for that pa...