M
markmarko
I've got a simple form for user to login. It only has 2 bound textboxes (User
and Word (password)), plus an Submit button. (I know this doesn't count for
'real' security, but it works for our purposes.)
I would like the user to be able to click Submit button, or hit <Enter>
after entering their info, which will then send their username to the
underlying table, close the form, and open the SalesOrder form.
Currently, typing <Enter> moves to the next record. And I'm having a hard
time getting it to send the data to the table.
I'm looking for suggestions in terms of Events to use, and code....
Here's the code I have so far.
Private Sub Form_BeforeUpdate(Cancel As Integer)
ValidateUser
End Sub
Private Sub SubmitButton_Click()
ValidateUser
End Sub
Public Sub ValidateUser()
Dim UsernameID As Integer
If Not (IsNull(Me!User)) Then
UsernameID = Me!User
If Word = DLookup("pWord", "pWords", "AssociatedContractor = " & Me!User)
Then
TempVars![TempUser] = UsernameID '
DoCmd.RunCommand acCmdSaveRecord 'this causes an error because of
BeforeUpdate
DoCmd.CancelEvent 'can't remember why I included this,
but there was a reason
DoCmd.Close
DoCmd.OpenForm ("Entry-SalesOrder")
Else
MsgBox ("Password Incorrect")
Me!User = UsernameID
Me!Word = ""
Me!Word.SetFocus
DoCmd.CancelEvent
End If
Else
MsgBox ("No PromoCode entered.")
Me!Word = ""
Me!User.SetFocus
DoCmd.CancelEvent
End If
End Sub
Private Sub SubmitButton_GotFocus()
ValidateUser
End Sub
and Word (password)), plus an Submit button. (I know this doesn't count for
'real' security, but it works for our purposes.)
I would like the user to be able to click Submit button, or hit <Enter>
after entering their info, which will then send their username to the
underlying table, close the form, and open the SalesOrder form.
Currently, typing <Enter> moves to the next record. And I'm having a hard
time getting it to send the data to the table.
I'm looking for suggestions in terms of Events to use, and code....
Here's the code I have so far.
Private Sub Form_BeforeUpdate(Cancel As Integer)
ValidateUser
End Sub
Private Sub SubmitButton_Click()
ValidateUser
End Sub
Public Sub ValidateUser()
Dim UsernameID As Integer
If Not (IsNull(Me!User)) Then
UsernameID = Me!User
If Word = DLookup("pWord", "pWords", "AssociatedContractor = " & Me!User)
Then
TempVars![TempUser] = UsernameID '
DoCmd.RunCommand acCmdSaveRecord 'this causes an error because of
BeforeUpdate
DoCmd.CancelEvent 'can't remember why I included this,
but there was a reason
DoCmd.Close
DoCmd.OpenForm ("Entry-SalesOrder")
Else
MsgBox ("Password Incorrect")
Me!User = UsernameID
Me!Word = ""
Me!Word.SetFocus
DoCmd.CancelEvent
End If
Else
MsgBox ("No PromoCode entered.")
Me!Word = ""
Me!User.SetFocus
DoCmd.CancelEvent
End If
End Sub
Private Sub SubmitButton_GotFocus()
ValidateUser
End Sub