By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,313 Members | 1,145 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,313 IT Pros & Developers. It's quick & easy.

Error 6: Overflow error

P: 2
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 cmdLinkExistingCaredFor_Click produces an Error 6: Overflow error.

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

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdLinkExistingCaredFor_Click()
  2. On Error GoTo Err_cmdLinkExistingCaredFor_Click
  3.  
  4. Set dbs = CurrentDb
  5. Set rst = dbs.OpenRecordset("SELECT * FROM tblPeople " & _
  6. "WHERE tblPeople.PersonType = 'Cared For' OR tblPeople.PersonType = 'Both' ")
  7. If rst.RecordCount > 0 Then
  8. Me.Tag = Me.CurrentRecord
  9. stLinkCriteria = "[CarerID]= " & Me.PersonID
  10. stDocName = "frmExistingCaredForByCarer"
  11. DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me.txtForeName & " " & Me.txtFamilyName
  12. Else
  13. MsgBox "There are NO 'Cared Fors' in the database."
  14. End If
  15.  
  16. Exit_cmdLinkExistingCaredFor_Click:
  17. Exit Sub
  18.  
  19. Err_cmdLinkExistingCaredFor_Click:
  20. Call LogError(Err.Number, Err.Description, Me.Name, "cmdLinkExistingCaredFor_Click")
  21. Resume Exit_cmdLinkExistingCaredFor_Click
  22.  
  23. End Sub
Any help would be much appreciated - was just trying to do someone a favour but got in a little over my head!!!
Oct 21 '07 #1
Share this Question
Share on Google+
2 Replies


FishVal
Expert 2.5K+
P: 2,653
Hi, Angie.

First localize faulty code.

Comment out
On Error GoTo Err_cmdLinkExistingCaredFor_Click
line and see where code execution stops.
Oct 21 '07 #2

nico5038
Expert 2.5K+
P: 3,072
Also add a test after the SET of rst or record(s) have been found like:
Expand|Select|Wrap|Line Numbers
  1. Set rst = dbs.OpenRecordset("SELECT ....
  2. IF rst.EOF and rst.BOF then
  3.     ' the action when there's no record found with e.g. a msgbox and an exit
  4. endif
  5.  
To have a correct recordcount you would also need to use:

Expand|Select|Wrap|Line Numbers
  1. rst.movelast
before testing the recordcount.

Nic;o)
Oct 22 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.