Results 1 to 10 of 10
  1. #1
    bmcclellan is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    6

    Error after upgrading to Access 2007

    I have a access DB that is now giving an error after I upgraded to Access 2007.

    This is the full code. The error is highlighted.

    Option Compare Database
    Option Explicit
    Private Sub cmdCancel_Click()
    DoCmd.Quit
    End Sub
    Private Sub cmdOK_Click()
    '20001010 JBT

    Dim RS As Recordset
    Dim SQL As String

    If Me.txtPassword.Value = "" Then
    MsgBox "PLEASE ENTER A VALID PASSWORD."
    Me.txtPassword.Value = ""
    Me.txtPassword.SetFocus
    Exit Sub

    Else

    If Len(Me.txtPassword.Value) <> 7 Then
    MsgBox "Passwords are 7 characters in length.", vbOKOnly
    Me.txtPassword.Value = ""
    Me.txtPassword.SetFocus


    Exit Sub
    End If
    End If

    SQL = "SELECT * FROM tblGECardHolders " & _
    "WHERE (((tblGECardHolders.Last7No)= '" & Me.txtPassword.Value & "') AND " & _
    "((tblGECardHolders.Inact)=No));"
    Set RS = CurrentDb.OpenRecordset(SQL, dbOpenSnapshot)

    If RS.RecordCount = 0 Then
    MsgBox "INVALID PASSWORD, PLEASE TRY AGAIN.", vbOKOnly
    CurrentDb.Close
    Me.txtPassword.Value = ""
    Me.txtPassword.SetFocus
    Exit Sub

    Else
    strPassword = RS.Fields(0)
    RS.Close
    DoCmd.OpenForm "frmGEMainMenu", acNormal, , , acFormAdd, acWindowNormal
    DoCmd.Close acForm, "frmBackground", acSaveNo
    DoCmd.Close acForm, "frmGELogon", acSaveNo
    End If

    CurrentDb.Close
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You have other problems with this code but for the error you are getting I would suggest disambiguating your libraries: Dim RS As DAO.Recordset

  3. #3
    bmcclellan is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    6
    I changed the line "Dim RS As Recordset" to "Dim RS As DAO.Recordset" I now get Error #13. Type mismatch.

    Thank you!

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Good! Is the Last7No field a string or a number? You are treating it as a string.

  5. #5
    bmcclellan is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    6
    it is a number

  6. #6
    bmcclellan is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    6
    Their login is the last 7 digits of their card.

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try not using the single quotes:
    SQL = "SELECT * FROM tblGECardHolders " & _
    "WHERE (((tblGECardHolders.Last7No)= " & Me.txtPassword & ") AND " & _
    "((tblGECardHolders.Inact)=No));"

  8. #8
    bmcclellan is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    6
    Compile error:

    User-defined type not defined

  9. #9
    bmcclellan is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    6
    This line is highlighted in VB

    Private Sub cmdOK_Click()

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try IMPORTING your db into an empty db and see if the problem follows. It sounds like you have some corruption.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Dll Error in Access 2007
    By preond in forum Import/Export Data
    Replies: 3
    Last Post: 02-09-2012, 11:16 PM
  2. Replies: 6
    Last Post: 12-01-2009, 11:59 AM
  3. Replies: 0
    Last Post: 11-17-2009, 02:35 PM
  4. Replies: 32
    Last Post: 09-16-2009, 10:06 AM
  5. converting from Access 2003 to Access 2007
    By LawrenceLau in forum Access
    Replies: 6
    Last Post: 11-20-2008, 03:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums