Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: finding access

  1. #1
    Join Date
    Aug 2004
    Posts
    178

    Unanswered: finding access

    i want to be able to find the access.exe file and its path and asign it to a string so i can output it to a batch file is this possable

    thank you

  2. #2
    Join Date
    Feb 2004
    Posts
    137
    SysCmd(acSysCmdAccessDir)

    ...will return the path to Access.exe. For example, if you type
    Code:
    ?SysCmd(acSysCmdAccessDir)
    ...in the Debug window and press [ENTER], it should return something like:
    C:\Program Files\Microsoft Office\Office\

  3. #3
    Join Date
    Aug 2004
    Posts
    178
    how do put that into a table

    because it wont go into the batch the way i want

  4. #4
    Join Date
    Feb 2004
    Posts
    137
    Your question was not how to put that into a table, you wanted to know how to put it into a string. I gave you the built-in function which returns this string.

    What does putting this into a table have to do with a batch file? This is not clear. What exactly do you mean by "batch file"?

    Perhaps if you explain more clearly, in more detail, exactly what you are attempting to accomplish, and by what means, it will be more possible to give you a specific answer.

  5. #5
    Join Date
    Aug 2004
    Posts
    178
    what i am trying to do is make all the FE update so i have created a batch.bat file which will copy the new FE over the old one. now i want to open the new FE. which means i have put in the path to msaccess.exe and the path to the new FE so it will open up. because batch are a bit like dos it does not like spaces i have to put it in " " so it will work. it dont make a difference witch way i do it i cant get the first " to go in if it does go in the rest wont. now if i put it into a text field i will then be able to extract it i hope. does this make it clear. thank you for you help

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    No, that will not help. for starters, msaccess.exe is registered in your path file and does not need to be explicitly called. Windows will implicitly know that files suffixed in mdb/mde/adp/ade are to be opened with access.

    The issue is FAR more likely to reside with your batch file itself.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  7. #7
    Join Date
    Aug 2004
    Posts
    178
    this is the code i am using

    Sub runBatchFile()
    Dim db As Database
    Dim BatchFileName As String
    Dim strCommand As String
    Dim strCommanda As String
    Dim strCommandb As String

    Dim htask As Variant
    Dim FileName As String, BackFile As String
    Dim tdf As TableDef
    Dim MasterFile As String
    Dim Response As Integer

    Set db = CurrentDb
    Set tdf = db.TableDefs("RemoteSystemObjects")
    MasterFile = Mid(tdf.Connect, 11)
    'MsgBox MasterFile

    FileName = db.Name
    'MsgBox FileName
    BatchFileName = "c:\Batch.bat"

    Open BatchFileName For Output As 2
    strCommand = "copy """ & MasterFile & """ """ & FileName & """"
    strCommanda = SysCmd(acSysCmdAccessDir)
    strCommandb = strCommanda & msaccess.exe & " """ """ & FileName & """
    Print #2, strCommand
    Print #2, strCommandb
    Close '*** Batfile.bat

    'MsgBox strCommand
    Response = MsgBox("Are you sure you want to continue?", vbYesNo)
    If Response = 6 Then
    htask = Shell(BatchFileName, 0) 'Run the Batch File
    End If
    End Sub

    this code creates the batch file
    these are the two lines it creates


    copy "\\Diamondserver\Data\keepinsync2.mdb" "\\Diamondserver\Data\REPORTS\keepinsync2.mdb"

    D:\Program Files\Microsoft Office\OFFICE11\msaccess.exe "\\Diamondserver\Data\REPORTS\keepinsync2.mdb"

    the second line is fine it is what i want but for the fact that there is no " at the start

    so i want to put the dir of access in a text field then take it out and put it in there

  8. #8
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    well, I just glanced real quick, but I noticed a couple of things:

    1.
    strCommandb = strCommanda & msaccess.exe & " """ """ & FileName & """
    msaccess.exe is meant to be part of the string and therefore should be in quotes. Also, save yourself some confusion - Chr(34) is the double quote.
    Code:
    strCommandb = strCommanda & "msaccess.exe" & " " & Chr(34) & FileName & Chr(34)
    2. Visual Basic is very touchy about doing things with files (like copy) when the file is in use (such as Open). I haven't tested using batch files for this purpose while files are in use, but I suspect it is susceptable to errors.

    I do something similar, using a couple API calls and a few standard conventions. I have an application where the FE resides on the network. Each user has a small executable that determines the presence and version of Access and Excel the user has (97, 2000, runtime, full, etc.). Providing the appropiate software is present, the program then copies the FE to the user's Temp directory using a crytic file name and then explicitly calls Access to open the file (since the file extension is not mdb).

    Among other things, this was meant to improve security (the FE and BE are both stashed away in an obscure location). It also makes updates a piece of cake - there is NEVER a user in the FE on the network, so I can post an update and then broadcast a message for all users to exit and reopen the application, causing an automatic update.

    Version, Location and other info about software is in the registry. So is the explicit location of the user's Temp folder.

    Hope this helps!

    tc
    have fun!

    Todd S.
    click to email


    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET


    _________________________________________________
    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

  9. #9
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Just out of curiosity, what version of Access are you using? Is there a reason you're not using the FileCopy method? Perhaps you could use a parameterized batch file (%1, %2 etc represent command line arguments). Also, are you trying to overwrite the currently running database? That may not work so well... Oh, and depending on version, why not use application.opencurrentdatabase?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  10. #10
    Join Date
    Aug 2004
    Posts
    178
    1 i am using access 2000
    2 my FE shuts down then runs the batch but i want the batch to run the FE again. i do know that msaccess.exe has to be in quotes and i can get them at the end no problem but if i put them at the start all i get is "strCommanda & msaccess.exe"


    hope this helps

  11. #11
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    What? How does the FE shutdown and still execute code? Are you doing some wacky thread monitoring that you're telling us about?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  12. #12
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    How does the FE shutdown and still execute code?
    Good point Teddy. My experience has been that if Process A starts Process B, and then closes itself, all appearences are that Process A is now closed, but it's an illusion - Process A doesn't truly close until Process B is done/closed.

  13. #13
    Join Date
    Aug 2004
    Posts
    178
    i put in behind a command

    runBatchFile
    DoCmd.Quit

    and it works

  14. #14
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    ok, so get to slide when using a batch file goes to show that the old DOS relic is better than the options Microsoft gives you .....

    It also tells us the problem is with the command line that opens your file in the batch file, not Access.

    Can you hand write a batch file that will do what you want? If not - get cracking. If so, post the contents of the batch file that works and we'll help you write the code that will create that batch file.

    There is a catch: are ALL of your front end workstations running the same version and same type of Access install? For example, the command line for Access Run-Time is different from the command line for Access Full-Install.

    tc
    have fun!

    Todd S.
    click to email


    Independent Development Consultant
    Biz db & reports - SQL, Access, Crystal, Seradex and more
    Small, custom, unique programs - Office, VBA, .NET


    _________________________________________________
    Favorite message from Windows:
    There was an error displaying the previous error message

    Sadly, there was no error number to look up ...

  15. #15
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by mega1
    i put in behind a command

    runBatchFile
    DoCmd.Quit

    and it works
    I still see a problem here. Open your access database and then perform the actions you want the batch file to do by hand. You may notice that it is somewhat difficult to overwrite a file that is already open...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

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