Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2010
    Posts
    4

    Unanswered: Access 2003 vs Access 2007

    Hi All,

    First up I am very inexperienced with Access, so please be patient with me....

    I have a piece of VB code that works in access 2003 but after migrating to 2007 gives me a run time error 13... Any ideas, nothing else has changed.. I can run it from 2007 in a 2003 version o.k. but not after converting.

    the code is (Probably really bad)

    TxtConsumer1.SetFocus
    Consumer_Number = TxtConsumer1.Text

    sqlSel = "SELECT Consumers.CONSUMERNUMBER, Consumers.LINECOMPANY, Consumers.INSTALLATIONID, " & _
    "Consumers.ACCOUNTNUMBER , Consumers.ENTRYDATE, Consumers.CONSUMERFINALEDDATE, " & _
    "Consumers.CREDITSTATUS, Consumers.COMPANY, Consumers.BILLNAMEFORMATTED, " & _
    "Installations.INSTALLATIONSTATUS, INSTALLATIONSTATUSCODES.Description, " & _
    "Installations.InstallationAddress, Installations.BUSINESSRESIDENTIAL " & _
    "FROM (Consumers INNER JOIN Installations ON Consumers.INSTALLATIONID = Installations.INSTALLATIONID) INNER JOIN INSTALLATIONSTATUSCODES ON " & _
    "Installations.INSTALLATIONSTATUS = INSTALLATIONSTATUSCODES.CODE " & _
    "WHERE ((Consumers.CONSUMERNUMBER) = " & Consumer_Number & ");"

    Set rstIn = db.OpenRecordset(sqlSel, dbOpenDynaset)

    If Not rstIn.EOF Then
    TxtAccount = rstIn![AccountNumber]
    TxtLine_Company = rstIn![linecompany]
    TxtInstall = rstIn![installationid]
    TxtStatus = rstIn![Description]
    TxtCompany = rstIn![Company]
    TxtBill_Name = rstIn![billnameformatted]
    TxtInstallation_Address = rstIn![InstallationAddress]
    TxtRes_Bus = rstIn![businessresidential]
    TxtEntry_Date = rstIn![entrydate]
    TxtFinal_Date = rstIn![consumerfinaleddate]
    TxtCompleted_By.Value = fSandBox.Environ("UserName") 'populate TxtCompleted_By
    If Format(Now, "HH:Nn") > "15:30" Then
    TxtDate_Completed = Date + 1
    Else
    TxtDate_Completed = Date
    End If
    Else
    MsgBox "Consumer Number not found."
    rstIn.Close
    Exit Sub
    End If
    rstIn.Close


    Any ideas..

    Thanks

  2. #2
    Join Date
    Oct 2009
    Posts
    340
    sorry - haven't memorized error code #s - - and you don't say which line it stops on....very difficult to assist.

  3. #3
    Join Date
    Mar 2010
    Posts
    4
    Sorry... New to the forum the Run Time Error 13 is a type mismatch and the code stops on line

    Set rstIn = db.OpenRecordset(sqlSel, dbOpenDynaset)

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    How do you declare db and rstIn?
    Have a nice day!

  5. #5
    Join Date
    Mar 2010
    Posts
    4
    Hi, thanks for your help...

    Dim db As Database
    Dim rstIn As Recordset

    Set db = CurrentDb()

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Not sure whether it will change something or not but try using a fully qualified declaration:
    Code:
    Dim db As DAO.Database
    Dim rstIN As DAO.Recordset
    Have a nice day!

  7. #7
    Join Date
    Mar 2010
    Posts
    4

    Smile

    That fixes it.... your a star...

  8. #8
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

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