Recycle combo box after message box

J

Joel

I have a combo box that is used to activate different forms after
validating username/password. However, I would like to have the combo
box recycle to a blank box when the password validation fails. I have
tried requery, refresh and setting the box to null without the correct
results. This is what I am working with.

Private Sub FormsCbo_AfterUpdate()

'Check to see if data is entered into the UserName combo box

If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required
Data"
Me.cboEmployee.SetFocus

Exit Sub
End If

'Check to see if data is entered into the password box

If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required
Data"
Me.txtPassword.SetFocus

Exit Sub
End If

'Check value of password in tblEmployees to see if this matches value
chosen in combo box

If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees",
"[lngEmpID]=" & Me.cboEmployee.Value) Then

lngMyEmpID = Me.cboEmployee.Value

'Open Next Form based on Combo Box Selection

DoCmd.OpenForm Me.FormsCbo.Column(2)

Else
MsgBox "The Password Invalid. Please Try Again", vbOKOnly,
"Invalid Entry!"
Me.txtPassword.SetFocus
End If

'If User Enters incorrect password 3 times database will shutdown

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database. Please
contact your system administrator.", vbCritical, "Restricted Access!"
Application.Quit
End If


End Sub

I don't know why I can't figure this out (maybe just be looking at it
too long)? Any help would be appreciated.
 
J

Joel

Thanks for the quick response but I have tried that option also. While
it does clear the combo box for me, it also clears any info I am trying
to pass to the next form. I believe that is the crux of my dilemma, I
want to be able to pass info and clear the combo box if the password
validation fails.
 
J

Joel

Ken, I have figured it out and using your advice. I thought the answer
should be a null value all along but I couldn't figure out what the
issue was. It ended up as "VB 101" - The placement location of the
statement....
 

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

Lock out a user from using a field 2
2 users - 1 login - 2 forms 1
username and password form 3
Macro to VBA 20
Choose Form that Loads Based on Login 6
Filtering...I think 3
Run Time Error 3075 2
Syntax error 6

Top