Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error number 3420? 1

Status
Not open for further replies.

Junior1544

Technical User
Apr 20, 2001
1,267
0
0
US
I am getting an error number 3420, and I'm not sure why.

this is what i'm tring to do.

I have a form that I am loading from the switch board. Now in the on open of this form i have some code that checks some security information... (I can provide all code as needed.)

It seems to be giving me this error from within the switchboard when it's tring to close a recordset. It seems that when my code to check security stuff runs, the recordset goes out of scope... why is this?? how can i stop it??

I am in a windows 2k enviroment, and am using access 2k. I have user level security in place, and am using this under an administrator account.

I'm confused... do i need to come at my function from a different angle??

(Code can be provided upon request.)

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Hi Junior1544.

Post the code. It's something to do with one of the Objects that is being referenced. My initial thoughts is that you may be trying to close the recordset twice but can't really say until I've seen the code.

Cheers,

Steve C. Make things as simple as possible — but no simpler.
 
That's what i thought, so i looked in the on open event of my form, and it doesn't deal with a recordset at all... it does deal with other things i don't know much about, buti will put all the code here...


the form open:

Private Sub Form_Open(Cancel As Integer)
If checkAdmin = False Then
MsgBox "You do NOT have access to use this menu.", vbCritical, Error
Cancel = True
End If

End Sub

The function CheckAdmin:

Function checkAdmin() As Boolean

Dim ws As Workspace
Dim grp As Group
Dim i As Integer
Dim Flag As Integer

Set ws = DBEngine.Workspaces(0)
Set grp = ws.Groups("Admins")
Flag = 0

For i = 0 To grp.Users.count - 1
If CurrentUser = grp.Users(i).name Then
Flag = 1
End If
Next i

If Flag = 1 Then
checkAdmin = True
End If

ws.Close
Set ws = Nothing

End Function

That is all the code I wrote, or was given.


The code behind the switchboard hasn't been touched...

On a side note, every thing seems to work fine... the menu continues to work, the form i made here works fine too... but i need to get rid of that error...

thank you so much for taking a look at this for me...

--James


junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
James,

I think that it is the last line in your code:-
Set WS = Nothing.
as you've used WS.Close in the previous line the code WS no longer exists. You are trying to set it to nothing but as it is closed it can't be set to any value including nothing.

Give this a go and let me know if it works.

Cheers,

Steve. Make things as simple as possible — but no simpler.
 
I hate those errors. My guess is that it's getting hung up calling the CurrentUser function inside of your loop. You might try setting a string to CurrentUser and using it for the compare. Also, I think (not sure) that raising errors in a form's open event will send the error back to the caller.

Here's what I've used successfully:
Code:
Public Function IsAdminUser() As Boolean
    Dim grp As DAO.Group
    On Error Resume Next
    Set grp = DBEngine.Workspaces(0).Users(CurrentUser()).Groups("Admins")
    IsAdminUser = (Err.Number = 0)
    Err.Clear
End Function

Kevin
:)
 
This last bit of code, what kind of responce does it give?? true if the person is an admin?? i think i'm going to try that...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Yes :) - it attempts to set a reference to the Admins group that the current user belongs to. If they don't belong, it generates an error as there will be no "Admins" Group in the "Groups" collection of the "User" object. The reference (i.e. grp) isn't used for anything other than seeing if an error gets generated. I suppose it would be a little cleaner to actually verify that the error returned is "Item not found in collection".

Kevin
 
I tried that piece of code and it alwas returned true... to i went back to my origanel code and took a look at the other suggestion... I eleminated a WS object, because it was only used to initiate the grp object, so I put it in there...

Set grp = DBEngine.Workspaces(0).Groups("Admins")

and it works great!

The problem wasn't the i put
ws.close
then
set ws = nothing
because I do that all the time, and if i loaded the form directly, there was no problem... it was only if I loaded the form from the switchboard...

So I just took the ws reference out, and it works great! Thank you so much guys... SteveCarey, here's a star:)

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top