Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

After update: VBA code does not work properly 2

Status
Not open for further replies.
Sep 10, 2002
16
NL
At my work they were using a database in access 97. But now we use access 2000. When we update the database he gives error. What should I do ?



If you need the code ... just ask
 
I've experienced the same problem a few years ago, This problem is why I'm programming in VBA nowadays. Most likely, your VBA code in your Access 97 database declares recordsets in a way that's no longer compatible with Access 2000. My Access 97 DB was originally made with even an earlier Access version.

Is the original programmer still available. Ask him or her to debug and if needed rewrite the VBA code. If not available, you'd best contract an experienced Access Db designer/VBA programmer.

Good luck, Bart Verlaan.
 
I think it culd be helpful to post the code as there a number of possibilities for problems when moving from 97 to 2000.

One of the most common problems I have come across relates to the ADO/DAO problem which has been very well documented in Tek-Tips, but there are others.

A couple of the typical symptons in code relate to references to recordset, database.

Hope this helps
 
Here is a part of the code ( the whole code is a bit long ). These are the 2 subs where are the problems about.

Private Sub Form_Current()
If IsNull(Me![PurchaseOrderID]) Then
DoCmd.GoToControl &quot;PurchaseOrderNumber&quot; <-- (this gives an error)
End If
End Sub

Private Sub PurchaseOrderNumber_BeforeUpdate(Cancel As Integer)

End Sub

He gives the following message:

Runtime error '2110':

Microsoft Access can't move the focus to the control PurchaseOrderNumber.
 
Accessgebruiker,

I don't see any strange things in the lines of code in you reply.

Perhaps you could replace
DoCmd.GoToControl &quot;PurchaseOrderNumber&quot;
by
Me!PurchaseOrderNumber.SetFocus
PurchaseOrderNumber should be the name of the control on the form you want to move to

Compile your VBA code after making the change and see if no compilation errors occur.

And for the rest, OldTom do you have any suggestions? Are there things I've overlooked?

Good luck, Bart V.
 
Are you calling these procedures from another Access form?

Has this form had a .show method on it before calling the procedure?

Bobbber : Bob x
 
No i'm calling the procedures from the same form..
and it has no .show method..

Maybe it will help if i tell you that I get this error when I make a new record. so when i'm in the last record of the table en I jump one more record further he gives that error.

 
This certainly helps. I think PurchaseOrderID either:
- doesn't exist yet;
- is not known to the form yet;
Is PurchaseOrderID the autonumbering field of your table (the table being the recordscource of your form)?
The event Form_Current is raised when:
- you switch to another record;
- when you create a new record.

Perhaps you could try this:
Private Sub Form_Current()
DoCmd.RunCommand acCmdSaveRecord
Me.Refresh
If IsNull(Me![PurchaseOrderID]) Then
DoCmd.GoToControl &quot;PurchaseOrderNumber&quot; <-- (this gives an error)
End If
End Sub

I'm not sure if Me.Refresh is absolutely needed, but on the other hand it does no harm either.
Don't ask me why this error didn't occur in the Access 97 version of your DB. I really wouldn't know.

I hope we finally helped you get rid of this error.

Good luck, Bart V.
 
Nahhh I'm so sorry... again it won't work. But the strange thing is: I get that error and if I click OK or Cancel he just still work properly. So is there a way to disable those error messages ??

Maybe there are some things that I overlooked so maybe its a good idea to empty the db and upload it tonight (I'm now at work, and have no permissions to do that). so you can take a look at it. I think thats going a lot faster than write messages.

But thanks so far anyway.
 
accessgebruiker,

If you want to 'disable' error messages, then trap for them in vba.

put in a statement( On Error goto <insert a label name>) at the top of the module that you want to trap errors in.

Then at the bottom of the module code the Error label and what you want done. Ex for error 2110

Public sub SomeSub()

on error goto ErrSub
{code here}

exit sub

ErrSub:

if err.number = 2110 then
Resume Next
endif

End sub

Use resume next to just ignore the error and keep processing on the line after the error was raised. Or you could do something else with the error. And don't forget to set up your environment to only break on Unhandled errors. Breaking on all errors would still stop the program even with error handling in it. To set this option, first make sure you are in the VBA window. Then choose TOOLS, OPTIONS.... Select the General tab and find the frame with error trapping.

Hope this helps!

Shannon
 
yeah thanks... I don't get the message anymore...
The problem still exist, but they can work again with it


William


Thanks anyone ofcourse who tried to help me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top