Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    File Locations in VBA (Win 2K Access 2K)

    Dear All

    I've been trying to set some code to refer to a file on my C: drive, the code looks similar to this: -

    Dim StrWorkBook as String

    Set StrWorkBook = "C:filename.ext"

    The rest of the code is supposed to open the file and save it as the current version, unfortunately the code doesn't get past the Set instruction, errors out with the message that the file doesn't exist and suggest I check the path or file name. I know that both are correct, read them back to myself about two dozen times by now.

    I know it's something stupid I'm missing, but for the life of me I can't spot it.

    Thanks for the help

    Ian

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: File Locations in VBA (Win 2K Access 2K)

    Just remove the Set. Set is used to assign a value to an object variable, for instance

    Dim frm As Form
    Set frm = Forms!frmMyForm

    But "ordinary" variables (string, numeric, boolean, date, ...) can be assigned a value using the form variablename = value.

  3. #3
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File Locations in VBA (Win 2K Access 2K)

    Doh!!!!!

    Like I said, it was going to be something stupid It was (me <img src=/S/smile.gif border=0 alt=smile width=15 height=15> ).

    Hans, thank you very much, yet again you've helped to both save my sanity and increase my ability. Congrats on the promotion / recognition as well, you deserve it.

    ian

Posting Permissions

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