Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Newtown, Pennsylvania, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    File Open/SaveAs Problems

    I have written a program to open a text file, work on it, then save it as another text file. In it, I use an API call that I got from the Access Web (<A target="_blank" HREF=http://www.mvps.org/access/api/api0001.htm>http://www.mvps.org/access/api/api0001.htm</A>). This was written for Access 97.

    Problem is that I am using Access 2000 (on Win 98 - either SE or original flavor, since I have reproduced the problem at home and at work). Everything works fine, except that if when I am trying to save the file as - creating a new file works great, but if I want to overwrite an existing file (this may happen!), it still appends to the end of the file.

    What changes do I need to make to enable overwriting the existing file?

    Many thanks,

    Kiwi44

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File Open/SaveAs Problems

    Can you post the code?
    It is almost impossible to help with problems like this one if you do not post the code!

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: File Open/SaveAs Problems

    I didn't wade through Ken Getz's code to see exactly where this would go. I use my own version of the calls, and it's too much effort to try to decipher someone else's.

    If you just want to overwrite the file automatically, insert a line like this somewhere before the save:

    on error resume next
    Kill strFileName

    where strFileName is the path and filename of the file you want to save. That will delete the old file if it exists. Then you just go ahead and save the modified file to the same path and filename.
    Charlotte

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File Open/SaveAs Problems

    Charlotte,

    I think the problem is not in the Open / Saveas dialog (that only gives you the path and name of the file you want to open or save) but in the way the file is actualy written.
    That is the reason I would like to see the code to get to the real problem.

  5. #5
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Newtown, Pennsylvania, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File Open/SaveAs Problems

    Dear Bart/Charlotte,

    Thanks for the response. I think I now understand what has to be done to get it to work. I'll come back to you if I have further difficulties.

    Thanks again,

    Kiwi44

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File Open/SaveAs Problems

    He, no problem, that's what the lounge is for!
    Glad I could help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •