Results 1 to 5 of 5
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    Unknown Error

    I am writing the following coded in the VB Editor of MS Access 2010



    Code:
    Sub TestErrRaise2(intValue1 As Integer, intValue2 As Integer)
      On Error GoTo HandleError
      Dim intResult As Integer
      If intValue2 <> 0 Then
       ' calculate result by dividing first value by second value
       intResult = intValue1 / IintResult2
      ElseIf intValue2 = 0 Then
       ' raise a custom divide by 0 error
       Err.Raise vbOjectError + 513, "TestErrRaise", _
         "The second value cannot be a 0."
      End If
    Exit Sub
    HandleError:
       MsgBox "An error has occurred in your application: " & Err.Description
       Exit Sub
    End Sub

    This is just variation on some code I found in a tutorial.
    Now when I try to run it I get

    "compile error expected =".

    What is wrong?

    Any help appreciated. Thanks in advance.


    Respectfully,

    Lou Reed
    Last edited by Lou_Reed; 09-21-2016 at 12:29 PM. Reason: correction

  2. #2
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, I got one of them. I changed the

    line

    Code:
    intResult = intValue1 / IintResult2
    to

    Code:
    intResult = intValue1 / intValue2
    It has not removed all errors but it did remove one.


    Now what about

    Code:
    Err.Raise vbOjectError + 513, "TestErrRaise", _
    It does not like that line.

    What is wrong with it.

    Thanks in advance.

    Respectfully,


    Lou Reed

  3. #3
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    It now says that

    vbOjectError

    is undefined.

    R,

    Lou Reed
    Last edited by Lou_Reed; 09-21-2016 at 01:10 PM. Reason: correction

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Now when I try to run it I get "compile error expected =".
    Do you compile your code whenever you make changes? That error message indicates you don't. You should ALWAYS compile your code after making even small changes; sometimes small changes aren't so small.

    Spelling mistake - it's vbObjectError, not vbOjectError

  5. #5
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, I got it. I thought that I took care of that error. thanks for your help.

    Respectfully,

    Lou Reed

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 06-26-2015, 10:31 AM
  2. Error on SendObject method - Unknown recipient
    By Glenn_Suggs in forum Access
    Replies: 4
    Last Post: 07-11-2013, 12:11 PM
  3. Unknown syntax error. Any spare eyes out there?
    By redbull in forum Programming
    Replies: 3
    Last Post: 08-31-2012, 11:55 AM
  4. Replies: 7
    Last Post: 01-26-2011, 08:31 PM
  5. Unknown Error
    By pimlicosnail in forum Forms
    Replies: 1
    Last Post: 02-26-2010, 10:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums