Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file open for output path 1

Status
Not open for further replies.

imarosel

Technical User
Jun 23, 2005
149
US
i'm trying to create files with access.

open "c:\path" & filename & ".txt" for output as #2
works

what would I put after open to have the file created in the current directory access is in without having to specify it in my code? that way i if the application was moved the files would be generated in the directory the application was moved to.
 
Perhaps simply this instead ?
Open filename & ".txt" For Output As #2

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
i tried that. strange thing happens. Program runs fine, but i cannot find any files. I'm pretty sure my code works because if I specify the path, my files show up.
 
i did find the files. they are put in my my documents folder when I do that. annoying.
 
And this ?
Open CurrentProject.Path & "\" & filename & ".txt" For Output As #2

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
that looks like that will work.

I found a command called cirdir that returns your current directory. defaults to my documents folder for some reason.

CurrentProject.Path gives me the correct path.

Awesome. Thanks.
 
replace(currentdb.Name,"your_database_file_name","")

This only works if you know that the filename of the database will never change. Otherwise, you'll need to be a tad more sophisticated about it:
Code:
    Dim strFileName As String
    strFileName = CurrentDb.Name
    While InStr(1, strFileName, "\") > 0
        strFileName = Right(strFileName, Len(strFileName) - InStr(1, strFileName, "\"))
    Wend
    strPath = replace(CurrentDb.Name,strFileName,"")
That's a better approach anyway, really.

TMTOWDI - it's not just for Perl any more
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top