I have never use 'workspaces' in Access, but, should they not still conform to 'scope' rules?
After quickly reading up on them...
I'm reading that 'workspaces' should not ever be 'closed'.
I'm assuming that you are declaring the 'WrkSpc' variable in a Module somewhere (so that it can be referenced by any object within the application).
The 'set' command:
Code:
[indent][/indent]Set WrkSpc = DBEngine.Workspaces(0)
...I am thinking should only be set once per session.
Is it not true that WrkSpc, is now pointing to a 'dynamic' workspace 'session' / a pointer to an object?
Therefore, you have no need to 'refresh' / 'requery' it?
So:
Create a Module (call it modWorkSpace).
Within it, use this code:
Code:
[indent][/indent]Dim Wrkspc as Object
[indent][/indent]Set Wrkspc = DBEngine.Workspaces(0)
This will only ever be 'called' once, and it will be called 'automatically' (no need for you to explicitly call it at all).
Define a sub within your form (as above) - (you had some fundamental errors in YOUR list population code):
Code:
Public Sub Refresh_Listboxes
[indent]Dim strUser As String[/indent]
[indent]Dim strUserList as string[/indent]
[indent]Dim strGroup As String[/indent]
[indent]Dim strGroupList as string[/indent]
[indent]Dim Usr As User[/indent]
[indent]Dim Grp As Group[/indent]
[indent]'(Don't use 'labels')...[/indent]
[indent][s]List_Users: ' displays all user accounts[/s][/indent]
[indent]For Each Usr In WrkSpc.Users[/indent]
[indent][indent]strUser = Usr.Name[/indent][/indent]
[indent][indent]If (strUser <> "Creator" And _[/indent][/indent]
[indent][indent][indent]strUser <> "Engine" And _ [/indent][/indent][/indent]
[indent][indent][indent]strUser <> "Admin"And _[/indent][/indent][/indent]
[indent][indent][indent]strUser <> "sysadm" And _[/indent][/indent][/indent]
[indent][indent][indent]strUser <> "") Then[/indent][/indent][/indent]
[indent][indent][indent]'Forming the delimited string list is different if NOT first item...[/indent][/indent][/indent]
[indent][indent][indent]If (Len(strUserList > 0)) Then[/indent][/indent][/indent]
[indent][indent][indent][indent]strUser = ";" & strUser[/indent][/indent][/indent][/indent]
[indent][indent][indent]EndIf[/indent][/indent][/indent]
[indent][indent][indent]strUserList = strUserList & strUser[/indent][/indent][/indent]
[indent][indent]End If[/indent][/indent]
[indent]Next[/indent]
[indent]'Populate the listbox once (NOT every For loop interation)...[/indent]
[indent]User_List.RowSourceType = "Value List"[/indent]
[indent]User_List.RowSource = strAccountName[/indent]
[indent]'(Don't use 'labels')...[/indent]
[indent][s]List_Groups: ' lists all group accounts[/s][/indent]
[indent]For Each Grp In WrkSpc.Groups[/indent]
[indent][indent]strGroup = Grp.Name[/indent][/indent]
[indent][indent]If (strGroup <> "Admins" And _[/indent][/indent]
[indent][indent][indent]strGroup <> "Users" And _[/indent][/indent][/indent]
[indent][indent][indent]strGroup <> "AdmGroup") Then[/indent][/indent][/indent]
[indent][indent][indent]'Forming the delimited string list is different if NOT first item...[/indent][/indent][/indent]
[indent][indent][indent]If (Len(strGroupList > 0)) Then[/indent][/indent][/indent]
[indent][indent][indent][indent]strGroup = ";" & strGroup[/indent][/indent][/indent][/indent]
[indent][indent][indent]EndIf[/indent][/indent][/indent]
[indent][indent][indent]strGroupList = strGroupList & strGroup[/indent][/indent][/indent]
[indent][indent]End If[/indent][/indent]
[indent]Next[/indent]
[indent]'Populate the listbox once (NOT every For loop interation)...[/indent]
[indent]Group_List.RowSourceType = "Value List"[/indent]
[indent]Group_List.RowSource = strGroupList[/indent]
End Sub
Call this Sub every time you want the listboxes re-populated...
Code:
[indent]Call Refresh_Listboxes[/indent]
Like I said, I haven't used Workspaces, however, how they are managed should be 'standard' stuff.
Try this, let us know if it made a difference.
ATB,
D