Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Find CURDIR of MS ACCESS (VB6, Access 97 and 2K)

    In VB6, I need to determine a machines CURDIR (or app.path) set in the user's Microsoft Access settings. I'm guessing that I would probably have to somehow search the registry to determine this. Any ideas?

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Find CURDIR of MS ACCESS (VB6, Access 97 and 2K)

    Hi Mike,
    Do you mean the location of the current database, the location of the Access executable file or the default database folder path? If it's the latter, you can use:
    Application.GetOption("Default Database Directory")
    If it's from VB6 I guess you'd need to either create an instance of Access or, as you said, check the registry.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find CURDIR of MS ACCESS (VB6, Access 97 and 2K)

    HI Rory,

    Thank you for your extremely quick response. I think that answers it. I need to see if a file exists in the default directory of the user's MS Access (usually defaults to My Documents).

    I gather that I would set a reference to Access in Project --> References, then set a variable equal to Access.Application? Would it then be objAccess.Application.GetOption("Default Database Directory") ?

  4. #4
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Find CURDIR of MS ACCESS (VB6, Access 97 and 2K)

    Mike

    In MS-Excel you do have the:
    Application.DefaultFilePath
    Application.AltStartupPath.

    In MS-Word you have the:
    Options.DefaultFilePath(Path:=wdDocumentsPath)
    Options.DefaultFilePath(Path:=wdUserTemplatesPath)
    Options.DefaultFilePath(Path:=wdAutoRecoverPath)
    and Others...

    I guess Access has the same when you open the Tools|Options|General tab and set the Default database Folder.

    I don't know if you need the registry for that, but then I am no Access developer?!

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  5. #5
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Find CURDIR of MS ACCESS (VB6, Access 97 and 2K)

    Pretty much - something along these lines:
    Dim appAccess As New Access.Application
    Dim strPath as String
    strPath = appAccess.GetOption("Default Database Directory")
    Set appAccess = Nothing
    Regards,
    Rory

    Microsoft MVP - Excel

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find CURDIR of MS ACCESS (VB6, Access 97 and 2K)

    Thanks Rory, that worked perfectly.

    One concern I have: This exe will be used to check the default directory of an Access 97 database as well, but I don't have an object reference for the Access 8.0 library. Do you think it will still work on both platforms?

    Mike

  7. #7
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Find CURDIR of MS ACCESS (VB6, Access 97 and 2K)

    To be honest I've never use VB itself, only VBA in Office apps so I'm not sure. If GetObject/CreateObject exists in VB, you might want to use that as you then won't need to actually set a reference to the Access Object Library. FWIW as far as I know, a reference to Access 9 should 'convert back' if you're using Access 8.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find CURDIR of MS ACCESS (VB6, Access 97 and 2K)

    I think you're right but the other way around. If I had Access 97 on my development computer I can set an object reference to the 8.0 library and I'll bet it will convert up on a 9.0 system, but not the other direction.

    I just tried compiling an exe and running it on a production system using Access 97 and it couldn't create the Access object. I'm going to take it to a machine that has both and try it...I'll let you know.

Posting Permissions

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