Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Oct 2003
    Location
    Nashville, Tennessee, USA
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    RecordSet not working? (Access 97)

    For some reason, it seams the code is working to an extent, however, it seems to only be allowing access for one password.

    Here is some quick Background for the code:
    Password info stored in Table = Plant
    Area Field = [Plant]
    Password = [Password]
    Executive Password = [Execpassword]

    The below code allows entrance to the form "Area1" only if the Execpassword is used. Any ideas as to why????

    Private Sub Area1_Edit_Click()
    Dim isgm As String
    Dim strSQL As String
    Dim db As Database
    Dim rs As Recordset
    Set db = CurrentDb()
    strSQL = "SELECT * FROM Plant WHERE Plant.Plant = 'Area 1 CST'"
    Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
    If rs.EOF Then
    MsgBox "There are no password for this Form, contact Administrator"
    GoTo Exit_Sub_Link
    End If
    isgm = InputBox("Enter Area1 Password")
    If (Len(isgm) > 0) Then
    If UCase(isgm) = rs.Fields("Password") Or UCase(isgm) = rs.Fields("ExecPassword") Then
    DoCmd.OpenForm "Area1", , , , , , ""
    Else
    MsgBox ("Incorrect Password for Tennessee")
    DoCmd.OpenForm "Switchboard", , , , , , ""
    End If
    End If
    Exit_Sub_Link:
    End Sub

  2. #2
    Star Lounger
    Join Date
    Oct 2003
    Location
    Nashville, Tennessee, USA
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: RecordSet not working? (Access 97)

    I do not understand about "Compare" at the top....
    But I went into the table and changed the password to all UpperCase and it is now working!

    I scrolled through the entire code for the form and did not see anything that resembling "Options...." Could you please explain where it is, or where it should be?

    The main thing is though, it is now working! Thanks!

    PBrown

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: RecordSet not working? (Access 97)

    There was a small but significant mistake in my earlier reply. Turns out the default is Option Compare Binary, i.e. case-sensitive comparison.

    You can put a line at the beginning of a module, before all declarations, procedures and functions, that specifies how strings are to be compared. There are three options:

    Option Compare Binary - case sensitive
    Option Compare Text - case insensitive, but diacritics matter:

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: RecordSet not working? (Access 97)

    <P ID="edit" class=small>(Edited by HansV on 11-Nov-03 17:01. Corrected default setting - originally stated erroneously that Option Compare Database is default.)</P>Which compare option do you have at the top of the module?

    If you have Option Compare Database or Option Compare Text, comparison is not case sensitive, so you don't need to use UCase.

    If you have Option Compare Binary, comparison is case sensitive. Since you apply UCase to the password entered by the user, the comparison will fail if the passwords in the table are not (entirely) in upper case. This is the default if you don't have Option Compare.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •