Login/VBA script to login to Access 2000



I new to Visual Basic and am struck on a issue. Have created a Login in
Screen for Remote User to access and input data. Want the Remote to be able
to login & access the Input Form, and Manager to Login to another screen to
view data.

Form 1 is rmFieldReq (Remote Users Form)
Form 2 is frmREquests (Manager Form)

Below is my Code

Private Sub cmdCancel_Click()
DoCmd.SetWarnings False
DoCmd.RunSQL "SELECT '' AS LoggedInAccess INTO access"
DoCmd.SetWarnings True
DoCmd.Quit acQuitSaveAll
End Sub

Private Sub cmdOK_Click()
DoCmd.SetWarnings False

'Check to see if they are a valid user

If DCount("[user]", "tblUser", "[user] = '" & txtUser & "'") = 0 Then
MsgBox "Get Away"
DoCmd.RunSQL "SELECT '' AS LoggedInAccess INTO access"
Exit Sub
End If


'Check password
Dim tempPass
tempPass = DLookup("[password]", "tblUSer", "[user] = '" & txtUser & "'")
If IsNull(txtPassword) Or txtPassword <> tempPass Then
MsgBox "Wrong Password"
DoCmd.RunSQL "SELECT '' AS LoggedInAccess INTO access"
Exit Sub
End If

'Write Field Office Name (access) in access Table
Dim FO
FO = DLookup("[FOID]", "tblUSer", "[user] = '" & txtUser & "'")

DoCmd.RunSQL "SELECT '" & FO & "' AS LoggedInAccess INTO access"


'Write Username (access) in access Table
Dim User
User = DLookup("[GROUPID]", "tblUSer", "[user] = '" & txtUser & "'")
If (GroupID) = requests Then
DoCmd.RunSQL "SELECT '" & GROUP & "' AS LoggedInAccess INTO access"
DoCmd.Close acForm, "frmLogin"
DoCmd.OpenForm "Requests", acNormal

Else

FO = DLookup("[FOID]", "tblUSer", "[user] = '" & txtUser & "'")
If IsNull(FOID) = FO Then
DoCmd.Close acForm, "frmLogin"
DoCmd.OpenForm "frmFieldReq"



'Test it
DoCmd.Close acForm, "frmLogin"
DoCmd.OpenForm "frmFieldReq"

'DoCmd.OpenQuery "qryPOEs"'

DoCmd.SetWarnings True


End Sub


thank you

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/200703/1

.



Relevant Pages

  • RE: Help! Access 2007 Login form problem
    ... Now the login form is generating the following error if you don't tab ... Private Sub Auto_Title0_Click ... 'If User enters incorrct password 3 times the database will shut down ...
    (microsoft.public.access.forms)
  • Forms Authentication Security questions...
    ... Login page, in you case default.aspx. ... string ReturnUrl=/admin/admin.aspx for late return. ... >Imports Microsoft.VisualBasic ... > Private Sub Page_Load(sender as Object, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: RedirectFromLoginPage
    ... Much appreciated Greg. ... > redirects you to page of choice after logging in. ... > If you do login succesfully, then attempt to go to page your are not ... > Private Sub Page_Load(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Allowing site Access
    ... Private Sub btnClear_Click(ByVal sender As System.Object, ... registration webForm (which links straight to Login if applicable for a ... and the target site, if necessary, into one site. ... redirect the user to the default.htm page of the target site upon completing ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Problem with web.config access-restricted subdirectory
    ... the login page when you acces the /Parent/Child/Default.aspx page. ... 'This call is required by the Web Form Designer. ... Private Sub Page_Init(ByVal sender As System.Object, ... the redirect still brings me back to ...
    (microsoft.public.dotnet.framework.aspnet.security)