1

In Microsoft Access, can you have Visual Basic identify what Workgroup you are using?

I find that new profiles need to be linked to the existing workgroup. Sometimes if the server crashes, Access doesn't find the workgroup and resets to the local workgroup.

HansUp
  • 95,961
  • 11
  • 77
  • 135
Scott
  • 71
  • 10

1 Answers1

1

The DAO.DBEngine object provides SystemDB property. You can retrieve the value of that property from VBA. Here's an example from the Immediate window.

? SystemDB
C:\Users\hans\AppData\Roaming\Microsoft\Access\System.mdw
HansUp
  • 95,961
  • 11
  • 77
  • 135
  • Cool. that works... half the time. Do I need a reference? I have a bunch of Databases. Half of them show the path & Workgroup. the other half shows blank (no length string). When the database opens and opens the main menu (form), I implimented an If-Then: comparing the SystemDB with the correct path to my MDW. if they don't match, then I show an error "You are in wrong workgroup" and quit the app. (else let them continue). Not fully implimented yet, but on 1 database it did work. Thank you! – Scott Aug 05 '13 at 19:20
  • If it was a reference issue, I don't think it would work even half the time. I didn't know it was possible for `SystemDB` to return an empty string. Are those ADP (Access Data Project) databases? – HansUp Aug 05 '13 at 19:32
  • Re References: Since I have multiple databases, each one may have different references. Re: ADP, no they are not. My understanding is ADP is Access front-end and SQL backend. We do have Access Front-end and Access back-end. – Scott Aug 05 '13 at 20:22
  • Its not working. I created a new database with 1 form. when the form opens, it has a message box to show the results of "systemdb". SO THEN... I'm part of a workgroup. I open the database, it asks for a username and password. I enter that. I Open the form, and a messagebox appears, but it is empty. Any thoughts? why wouldn't systemdb return the workgroup path? – Scott Aug 08 '13 at 21:58
  • Instead of SystemDB, should I use DBEngine.systemdb? – Scott Aug 08 '13 at 22:04
  • You can try that but my best guess is it won't make any difference. What do you get in the Immediate window with `? CurrentUser` ... that should give you the name of the Access workgroup account you supplied when logging in. – HansUp Aug 08 '13 at 22:07
  • it didn't make a difference :( I did ? currentuser and it came up correctly. then i did (immediately) ? systemdb. it came up blank! arg! – Scott Aug 19 '13 at 17:21