Case Sensitivity being lost?

G

Guest

Hi I need some help with comparing a control value to a recordset value.

Was wondering if any of you EVER seen something like this?

This is my code from my form when the subm,it button is clicked
Private Sub cmd_Submit_Click()
On Error GoTo Err_cmd_Submit_Click
Dim rs As New ADODB.Recordset
rs.Open "qryGetAdminInfo", Application.CurrentProject.Connection,
adOpenForwardOnly, adLockReadOnly
If (Not rs.EOF) Then
If (Me!txt_password = rs!AdminPassword) Then
Forms!frmSwitchBoard!cmd_DataMgmt.ForeColor = 0
Forms!frmSwitchBoard!cmd_ReportMgmt.ForeColor = 0
Forms!frmSwitchBoard!cmd_AdminMgmt.ForeColor = 128
Forms!frmSwitchBoard!frmSwitchBoardsub.SourceObject =
"frmSwitchBoardAdminMgmtsub"
DoCmd.Close acForm, Me.Name
Else
MsgBox "Sorry incorrect password", vbExclamation
DoCmd.Close acForm, Me.Name
End If
Else
MsgBox "Was not able to access password", vbCritical + vbOKOnly,
"SQL ERROR"
DoCmd.Close acForm, Me.Name
End If
Exit_cmd_Submit_Click:
On Error Resume Next
If rs.State = adStateOpen Then rs.Close
Exit Sub

Err_cmd_Submit_Click:
MsgBox "Error " & Err.Number & ": " & Err.Description, , Me.Name & _
": cmd_Submit_Click"
Resume Exit_cmd_Submit_Click
End Sub

When debugging this is the information pulled out

?rs!AdminPassword, me!txt_Password

GorgeousOne GORGEOUSONE

?rs!AdminPassword= me!txt_Password

True

Now, this is a password window. Rs is the recordset that returned with the
password from the database. Me!txt_Password is the typed/inputted field in.

It keeps letting me in EVEN though the passwords typed are obviously NOT the
same….As shown with the debug results..

Any help is greatly appreciated.

Angela
 
D

Douglas J. Steele

Access has never been case sensitive.

To do a case sensitive comparison, you need to use the StrComp function. Try
replacing

If (Me!txt_password = rs!AdminPassword) Then

with

If StrComp(Me!txt_password, rs!AdminPassword, vbBinaryCompare) = 0 Then
 

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