Need code to write a user sign on form for access

A

Akbar Siddiqui

I developed an application using access for 8 users. Now I need to write code for users sign on Form. Can anybody help

Thanks
 
S

Scott Sandor

Create a log on form to open on the applications open. The form is a text box to enter a user name and 2 buttons. One to log on and one to exit the application. A table is setup to house user ids and names. Below is the code that executes when a user clicks log on

Private Sub logon_b_Click(

'Check to ensure the user id is valid before continuing

Me.Refresh 'update the underlying recordse

Dim dbs As Databas
Dim switchboard As Recordse
Dim codeset As Recordse
Dim uid

Set dbs = CurrentD
Set switchboard = dbs.OpenRecordset("Switchboard", dbOpenTable
Set codeset = dbs.OpenRecordset("0 username", dbOpenDynaset

Me.Refresh 'update the underlying recordse

uid = Trim(switchboard!user_id

If codeset.EOF = False The
'MsgBox "The user id " & uid & " is ok" 'for testin
DoCmd.OpenForm "Switchboard" 'open the MainBoard for
DoCmd.Close acForm, "Logon", acSaveYes 'close the Logon for

Els
MsgBox "The user id " & uid & " is not valid. Try again
Me.Text2.SetFocus 'goto the user id fiel
End I
End Su
 

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