Edit Form

A

Andrew C

Hi

I have a form with a Tab control on it with various sub forms on each tab.
Each page of the Tab box has been enable set to no. So that users can view
information with accidently changing. At the top of the page is a button
"EDIT" that when clicked changes these properties to 'Yes' so that users can
change information

I now want when users click the edit button that a pop up box appears and
they have to enter their username and password to be able to edit this
informaiton. Also i wish to record the username in a field against the
record.

The user name info is stored in Table called 'Access' and fields 'Name' and
'Password'.

The Field to store the username is Table 'Client' Field is 'Updated By'

Im have reasonable knowledge of access but if you more information please
let me know.

Cheers

Andrew
 
K

Kipp Woodard

I use the user's domain login info in my app, instead of keeping and managing
separate logins. In my environment each user is required to login to
whichever machine they are using as themselves. If this is the case in your
environment, then I strongly recommend that you leverage the domain login
information that is available to you.

If you cannot depend on the machine login info to indentify the user and
thus are stuck having to do your own authentication... There's a bit of work
to do.

I would create a function that returns the login name, or an empty string if
the login fails or is canceled. This function might look like this:

=====================
Public Function HandleLogin() As String
Const PROC_NAME As String = "HandleLogin"

On Error GoTo ErrorHandler

DoCmd.OpenForm "frmLogin", acNormal, , , acFormEdit, acDialog

Cleanup:
HandleLogin = TempVars!LoginName

Exit Function

ErrorHandler:
MsgBox "Error: " & Err.Number & ", " & Err.Description, , PROC_NAME

On Error Resume Next

GoTo Cleanup

End Function
=====================

The form, frmLogin, would have text boxes for username and password, and
buttons for OK and Cancel.

If the user enters the right password for the username that they enter, then
you can set TemVars!LoginName to the username, otherwise set
TemVars!LoginName to "".

Then your click code for your button would look like this:

=======================
Private Sub cmdUnlock_Click()
Const PROC_NAME As String = "cmdUnlock_Click"

Dim sLogin As String

On Error GoTo ErrorHandler

sLogin = HandleLogin

If Len(sLogin) = 0 Then
Exit Sub
End If

''' Unlock code here....


''' Code to record the username here...

Cleanup:
Exit Sub

ErrorHandler:
MsgBox "Error: " & Err.Number & ", " & Err.Description, , Me.NAME & "."
& PROC_NAME

On Error Resume Next

GoTo Cleanup

End Sub
=======================
 

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

Top