Error 6: Overflow error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AngieMP
    New Member
    • Oct 2007
    • 2

    Error 6: Overflow error

    Hi Guys

    I have inherited an Access DB in a very poorly state! I have offered to make some changes to it for a local charity but have got stuck on this error it seems to be creating for all new records.

    I am working within a Form which is calling another Form matched on the ID, this is within Access 2000. Clicking the cmdLinkExisting CaredFor_Click produces an Error 6: Overflow error.

    Can anyone help me as to what maybe making the code fall down?

    Code:
    Private Sub cmdLinkExistingCaredFor_Click()
    On Error GoTo Err_cmdLinkExistingCaredFor_Click
    
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("SELECT * FROM tblPeople " & _
    "WHERE tblPeople.PersonType = 'Cared For' OR tblPeople.PersonType = 'Both' ")
    If rst.RecordCount > 0 Then
    Me.Tag = Me.CurrentRecord
    stLinkCriteria = "[CarerID]= " & Me.PersonID
    stDocName = "frmExistingCaredForByCarer"
    DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me.txtForeName & " " & Me.txtFamilyName
    Else
    MsgBox "There are NO 'Cared Fors' in the database."
    End If
    
    Exit_cmdLinkExistingCaredFor_Click:
    Exit Sub
    
    Err_cmdLinkExistingCaredFor_Click:
    Call LogError(Err.Number, Err.Description, Me.Name, "cmdLinkExistingCaredFor_Click")
    Resume Exit_cmdLinkExistingCaredFor_Click
    
    End Sub
    Any help would be much appreciated - was just trying to do someone a favour but got in a little over my head!!!
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Hi, Angie.

    First localize faulty code.

    Comment out
    On Error GoTo Err_cmdLinkExis tingCaredFor_Cl ick
    line and see where code execution stops.

    Comment

    • nico5038
      Recognized Expert Specialist
      • Nov 2006
      • 3080

      #3
      Also add a test after the SET of rst or record(s) have been found like:
      Code:
      Set rst = dbs.OpenRecordset("SELECT ....
      IF rst.EOF and rst.BOF then
          ' the action when there's no record found with e.g. a msgbox and an exit
      endif
      To have a correct recordcount you would also need to use:

      Code:
      rst.movelast
      before testing the recordcount.

      Nic;o)

      Comment

      Working...