Results 1 to 7 of 7

Thread: VBS Error

  1. #1
    Join Date
    Dec 2011
    Posts
    4

    Unanswered: VBS Error

    I am writing a vbs to open access and clone the file for each user, as to avoid some of the lock errors. However, I have hit a roadblock. Access will open, and it will save the new file with the username, but it doesn't open the database, and I keep receiving this error: "The command line you used to start Microsoft Access contains an option that Microsoft Access doesn't recognize." I can not seem to figure out what is causing this error.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I can not seem to figure out what is causing this error.
    given the lack of information, no idea of the script you are running or the options you are starting Access neither can we

    my guess would be that you are not supplying the right parameters to start Access. it could be because there is a space in say a filename. but as said above thats a guess as you haven't provided any information to go on
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Dec 2011
    Posts
    4

    My VBS

    I do have spaces in the file name, and the path. I've tried a couple of different solutions to get around the spaces to no avail. Here is what I have:


    Set WshNetwork = CreateObject("WScript.Network")
    GetUser = WshNetwork.UserName
    Set WshNetwork = Nothing


    LUName = "S:\CP_Students\2011\Fall 2011\Cory Colin\CSI Registrants2011-12\CSI REGISTRANTS.accdb"


    oldname = LUName


    newName = Replace(LUName, ".accdb", "") & GetUser & ".accdb"

    retval = 0
    Dim objFSO
    Set objFSO = CreateObject("Scripting.FileSystemObject")


    retval = objFSO.CopyFile(oldname, newName, True)

    Set objFSO = Nothing

    Dim objShell
    Set objShell = CreateObject("Wscript.Shell")

    objShell****n "MSACCESS.exe " & newName

    Set objShell = Nothing


    I'm not very talented with computer language, so I've patched together some other scripts I've used to the best of my ability. This is what I've come up with, and obviously it is not correct.

    Thanks

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    try
    LUName = "S:\CP_Students\2011\Fall20~1\CoryCo~1\CSIReg~1\CS IReg~1.accdb"
    8.3 filename - Wikipedia, the free encyclopedia

    to convert long file names to 8.3 format
    drop any spaces, take the first 6 characters use a tilde ~ and a single digit number indicating the index of the file
    the potential issue you have is

    LUName = "S:\CP_Students\2011\Fall 2011\Cory Colin\CSI Registrants2011-12\CSI REGISTRANTS.accdb"
    csi registrants 2011-12
    csi registrants 2012-13
    would both have the same initial 6 characters
    csireg
    one would be ~1, one ~2, Im guessing base on the age of the files creation or possibly filename.
    you will run out of filenames after 9, possibly 10.
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Dec 2011
    Posts
    4

    New Error

    Ok, I've replaced the path with 6 characters and tilde and now it's telling me there is an error in this line:

    retval = objFSO.CopyFile(oldname, newName, True)

    It is no longer opening access.

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    and the error message is?
    the values of the variable used int he method call to the File System Object. are?



    no wait, doesn't matter, I'll just get me crystal ball and scriving mirror out and I'm sure we will all be able to work out what is going wrong with your script

    OK on the count of 3, lets turn the lights down low, everyone from a circle and hold hands mumbling some arcane chant and we work out the code from the thoughts of a dead programmer who intends to pass a message from the other side
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Dec 2011
    Posts
    4
    800A0035 file not found

Tags for this Thread

Posting Permissions

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