tags:

views:

41

answers:

1

I am doing the following in code to set the default workgroup file:

Application.SetDefaultWorkgroupFile "c:\myworkgroup.mdw"

How do I find out what the current workgroup is before I do this so I can revert? Is there something built into Access?

Thanks, Greg

+2  A: 

I'm not aware of a method or property to return the current workgroup file. However, you can extract it from CurrentProject.Connection when you have a database open in Access.

Public Function CurrentWorkgroupFile() As String
    Dim strSplit1 As String
    strSplit1 = Split(CurrentProject.Connection, "System database=")(1)
    CurrentWorkgroupFile = Split(strSplit1, ";")(0)
End Function

Edit: I think the Split() function is available in Access versions starting with 2000. If your Access version is older, you will need to extract the workgroup file location by another method.

Edit2: Read about DBEngine.SystemDB in the comments following this answer.

HansUp
Er, is there some reason to not use DBEngine.SystemDB?
David-W-Fenton
Did you mean a reason other than lack of awareness? :-)
HansUp
DBEngine.SystemDB is it. Thanks!
Greg Finzer
Now that was interesting. David gave you the answer, but I got the points.
HansUp
There's some confusion in the question. The default workgroup file may be completely different from the one that is being used by a particular instance of Access. And even for an instance of Access using the default, changing the setting for the default workgroup file won't change the workgroup file being used in that instance of Access.
David-W-Fenton
OK. I was just a little uncomfortable about being awarded your points. OTOH, I figured that since neither your nor I give a good rat's fanny about points, it maybe didn't matter.
HansUp
You need to catch up with me and get your Silver MS-ACCESS badge, so have some points!
David-W-Fenton
That's a pretty exclusive club; just you and Remou! Is there a financial reward?
HansUp
I'll never tell! You'll have to find out yourself! I just got you one upvote closer...
David-W-Fenton
Thank you. Every votes help my quest for silver. :-)
HansUp