[access 2000] 7 lines that are killing me

ed_the_unlucky

Registered User.
Local time
Today, 12:13
Joined
Jan 28, 2008
Messages
30
Code:
Private Sub Form_Open(Cancel As Integer)
    Dim sUser As String
    Set sUser = GetWinUserName
If sUser <> "[user1]" Or "[user2]" Or "[user3]" Then
    Cancel = True
End If

End Sub
"getwinusername" is a separate module.

OK, so why won't this code run? i've been beating my head against this for a lot longer than i care to admit, i'll confess.

the desired activity: check for the windows account name (using the module described above), compare to the expressed values in the if/then statement and either permit the access 2000 form to go on opening or close.

thoughts, anyone?

ed
 
Try

If sUser <> "[user1]" AND sUser <> "[user2]" AND sUser <> "[user3]" Then

Would the user really have the brackets? That has to match exactly whatever is returned by the function.
 
pbaldy, thanks for the suggestion.

i tried using the code you suggested, and the error msg i get remains the same: compile error: object required. the error must lie elsewhere but darned if i can figure out where.

ed
 
Post the code for GetWinUserName. It sounds like it wants something passed to it. And, we may be able to replace it completely.
 
moniker: OK, here it is...

Code:
Function GetWinUserName()
    GetWinUserName = VBA.Environ("UserName")
End Function
it's fairly straightforward, and i use this value elsewhere as well--it displays on the switchboard, so i know the code is working properly.

ed
 
And the debugger should go to the line with the problem. Which is it?
 
There it is. Change this:

Set sUser = GetWinUserName

To this:

sUser = GetWinUserName

You don't have to set a string.

If that's not it, please say what line it's stuck on (as pbaldy suggested).
 
Duh; didn't even see the Set.
 
pbaldy: to answer the question, it was stuck on the first line of the procedure.

moniker: my thanks--that was it!

now, if you'll excuse me, i shall go now and hang my head in shame. thanks again!

ed
 

Users who are viewing this thread

Back
Top Bottom