Error When Converting to Access 2007 Record Not Available

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • simulationguy
    New Member
    • Feb 2010
    • 27

    Error When Converting to Access 2007 Record Not Available

    I inherited an Access 2003 database runs fine in 2003 but in 2007 I get an error on updating a form. Record Not available on the last statement
    !ItemNumber.Set Focus

    Does anyone know why Access 2007 is different and any clues on how to get it to work?

    Code:
    With Forms!frmMain!frmSKUInput.Form
        !WhichSKUCombo.Value = ""
        !WhichSKUList.Value = ""
        .RecordSource = strSQL1
        .Requery
        !WhichSKUList.RowSource = strSQL2
        !WhichSKUCombo.RowSource = strSQL2
        !WhichSKUList.Requery
        !WhichSKUCombo.Requery
        !ItemNumber.SetFocus
    End With
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    Where do you want to be in the recordset? If at the beginning, try adding a .movefirst after the .requery.

    But I suspect the recordset may be empty. Have you tried monitoring through and looking at the value in strSQL1? I don't see you setting any value for that, is that a global variable? If so, it should have a g in the name to indicate that. Ditto strSQL2

    Jim

    Comment

    • simulationguy
      New Member
      • Feb 2010
      • 27

      #3
      Thanks, I tried adding .movefirst after the requery but it gave me an error, Run-time error '2465' Application-defined or object defined error.

      The strSQL statements get initialized just befort the with loop, I just didn't show them to make the code shorter. What I don't get is it all works with 2003.
      I just want to go to the first record in the set

      Any help would be greatly appreciated

      Code:
       strSQL1 = _
          "SELECT tblItem.ID, tblItem.ItemNumber, tblItem.ItemDescription, tblItem.TypeID, tblItem.FamilyID, tblItem.BaseQty, tblItem.BaseUnitID, tblItem.File, tblItem.UnitsPerCase, tblItem.UnitsPerSU, tblItem.QtyPerPallet, tblItem.QPPUOMID, tblItem.Bulk, tblItem.StorLocID, tblItem.WE, tblItem.ForecastPct, tblItem.BulkTruckKg, tblItem.BulkCapicityKg " & _
          "FROM tblCompCat INNER JOIN tblItem ON tblCompCat.ID = tblItem.TypeID " & _
          "WHERE tblCompCat.ClassificationID = " & TypeID & " ORDER BY tblItem.ItemNumber"
      
      strSQL2 = _
          "SELECT tblItem.ID, tblItem.ItemNumber, tblItem.ItemDescription " & _
          "FROM tblCompCat INNER JOIN tblItem ON tblCompCat.ID = tblItem.TypeID " & _
          "WHERE tblCompCat.ClassificationID = " & TypeID & " ORDER BY tblItem.ItemNumber"

      Comment

      • jimatqsi
        Moderator Top Contributor
        • Oct 2006
        • 1293

        #4
        Well, obviously error 2465 on a simple .movefirst tells us something is seriously wrong. I might delete the form and import from a backup copy of the DB and see if it behaves the same way.

        Jim

        Comment

        • colintis
          Contributor
          • Mar 2010
          • 255

          #5
          If you are declaring variables within the form's coding module, you can skip all those [Form]! things. As one thing you need to double check, the format that's accepting by Access 2007 and 2003 are different. Such as Forms!frmMain needs to be [Forms]![frmMain].

          Comment

          Working...