Password for Open Form

D

D

Hi:

I have the API function that gets the Windows login; for every login ID I
have a password.

Can you please tell me what should be in the below code to open the form?/
what am I missing?

Thank you,

Dan

If fOSUserName() = "what should be here?" Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Invalid Passowrd", vbOKOnly
DoCmd.CancelEvent
End If
 
D

Douglas J. Steele

fOSUserName is the name of the function in
http://www.mvps.org/access/api/api0008.htm at "The Access Web". All it's
going to do is provide you with the user's ID, not his/her password. If
you're saying that you've stored a password in a table in Access,
realistically you've wasted your time, as you won't be able to stop anyone
from using your application.

You could issue a Windows Challenge, as outlined by Randy Birch at
http://vbnet.mvps.org/code/network/acceptsecuritycontext.htm so that they're
forced to provide their Windows password, which would be validated by
Windows, but I really don't understand why you'd bother.
 
D

D

Hi Doug:

Thank you!

Yes I know it is not realy a 'security'; it is just to give them 'some'
protection feeling.

I think the following will do it, for now.

Thanks gain,

Dan
****

Private Sub Command4_Click()
Dim stDocName As String
Dim stLinkCriteria As String
Dim psw As String

stDocName = "hcc"
Call Module1.fOSUserName
strPsw = InputBox("Please enter your password")
If strPsw = True Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Invalid Password", vbOKOnly
DoCmd.CancelEvent
End If

End Sub
 
D

Douglas J. Steele

So essentially you're saying as long as they provide something, they can get
in?

You do realize that if they simply hit Enter, you'll get a Type Mismatch
error?

As well, Call Module1.fOSUserName is meaningless: it's a function that
returns the user id. If you're not going to do anything with the user id,
don't bother with the call. If you want to know the user id, assign the
result of the function to a variable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

fOSUserName 17
DLookup 2
FindFirst not finding first login/password attempt 1
If Statements 2
Open Sub Form 6
Using a wildcard to open a form 2
Open with Link Criteria and Columns in Datasheet 1
Parameter error box 3

Top