Connecting Tech Pros Worldwide Help | Site Map

VBA runtime 6 error-MS Access 2003

Newbie
 
Join Date: Jun 2007
Posts: 12
#1: Jun 25 '07
I have a MS Access 2003 database that I have inherited and has been in service for about 2 years now. Suddenly, we are getting a vba runtime error "6". I have done some research and what I have found is that this might have to do with the field being an interger field, and can only be numbered up to 32000 or so. Currently the id for this field is at 32767.

However in the table the field is coded as a long interger. The vba code that is being returned as causing the error is as follows:

Private Sub Form_BeforeUpdate(Cancel As Integer)
AddChangeLogItem Me.Controls, "contact", Nz(Me.contactid)
End Sub

If it truley is the numbering that is causing the issue, I know that this database was imported from Goldmine about 2 years ago and with all the records deleted during that conversion the numbering for this field began at 28523. Is there a way to change the numbering to begin at a lesser number (this is a primary key on this particular table) which will not adversley effect the other tables that have relationships with it?

Thanks so much in advance.
msquared's Avatar
Administrator
 
Join Date: Aug 2006
Location: Dublin, Ireland
Posts: 10,865
#2: Jun 29 '07

re: VBA runtime 6 error-MS Access 2003


Changing the primary key at this stage would be a nightmare.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.     AddChangeLogItem Me.Controls, "contact", Nz(Me.contactid)
  3. End Sub
This code calls a function AddChangeLogItem. We would need to see the code for this function.

Also Nz(Me.contactid) doesn't indicate what to return if null. It would normally show ....

Nz(Me.contactid, 0)
Newbie
 
Join Date: Jun 2007
Posts: 12
#3: Jul 11 '07

re: VBA runtime 6 error-MS Access 2003


Thanks for the reply, I was able to go into the VBA code and find where the "contactid" had been declared as an integer and change it to Long, everything working fine now!! Just had to dig through mucho code to find it.
Reply