+ Reply to Thread
Results 1 to 3 of 3

Application-defined or object-defined error on one machine but not the other

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-19-2004
    Posts
    252

    Application-defined or object-defined error on one machine but not the other

    I'm trying to figure out why I can run a bit of code on my machine but on another machine I get an:
    Application-defined or object-defined error

    The code is in an excel file on a network drive and it pulls up a form, once the form is submitted it runs some code that looks like so
    Sub ajbkMargin2()
    Dim strfirst, strletter, Coststrfirst, Coststrletter, ICstrfirst, ICstrletter, Packstrfirst, Packstrletter, strnumber As String
    Dim Margin, RowAnswer, CIPdecision, RowMyNote As String
    Dim LastRow, i As Long
    Dim objAccess As Object
    
    frmCIP.Hide
        
    'If the particular radio button is selected, change the value of the boolean as True
    If frmCIP.OptCalcDnet.Value = True Then
        CIPdecision = "aDNET"
    ElseIf frmCIP.OptMarginDecimal.Value = True Then
        CIPdecision = "aMarginDecimal"
    ElseIf frmCIP.OptMarginInteger.Value = True Then
        CIPdecision = "aMargin"
    End If
    
    ' START GET COLUMN LETTER
    Coststrfirst = IIf(Chr$(64 + Range(frmCIP.RefEditCost).Column \ 26) = "@", "", Chr(64 + Range(frmCIP.RefEditCost).Column \ 26))
    Coststrletter = Coststrfirst & Chr$(64 + Range(frmCIP.RefEditCost).Column Mod 26)
    ICstrfirst = IIf(Chr$(64 + Range(frmCIP.RefEditIC).Column \ 26) = "@", "", Chr(64 + Range(frmCIP.RefEditIC).Column \ 26))
    ICstrletter = ICstrfirst & Chr$(64 + Range(frmCIP.RefEditIC).Column Mod 26)
    Packstrfirst = IIf(Chr$(64 + Range(frmCIP.RefEditPack).Column \ 26) = "@", "", Chr(64 + Range(frmCIP.RefEditPack).Column \ 26))
    Packstrletter = Packstrfirst & Chr$(64 + Range(frmCIP.RefEditPack).Column Mod 26)
    strfirst = IIf(Chr$(64 + Range(frmCIP.RefEditRes).Column \ 26) = "@", "", Chr(64 + Range(frmCIP.RefEditRes).Column \ 26))
    strletter = strfirst & Chr$(64 + Range(frmCIP.RefEditRes).Column Mod 26)
    strnumber = Range(frmCIP.RefEditRes).Row
    ' END GET COLUMN LETTER
    
    Unload frmCIP
    
    ' START MACRO WILL STOP AT ROW _? QUESTION
    
    'Place your text here
    RowMyNote = "Your top cell is " & strletter & strnumber & ", is that correct?"
    
    'Display MessageBox
    RowAnswer = MsgBox(RowMyNote, vbQuestion + vbYesNo, "???")
    
    If RowAnswer = vbNo Then
        'Code for No button Press
        Exit Sub
    Else
    ' END MACRO WILL STOP AT ROW _? QUESTION
    
    ' OPENS GREGG'S DESCRIPTION_CLEANER DATABASE
    
        Set objAccess = GetObject _
           ("O:\Common\Common-Parts\Prcng\Macros\Macros.accdb")
            With objAccess
                .Visible = False
            End With
        
        LastRow = Range(Coststrletter & "65536").End(xlUp).Row
            For i = LastRow To strnumber Step -1
                Debug.Print Range(strletter & i).Address, Range(strletter & i).Value
                Margin = objAccess.Run(CIPdecision, Range(Coststrletter & i), Range(ICstrletter & i), Range(Packstrletter & i))
                Range(strletter & i).Value = Margin
            Next
    
    ' END IF FOR MACRO WILL STOP AT ROW _? QUESTION
    End If
    ' END IF FOR MACRO WILL STOP AT ROW _? QUESTION
    
    MsgBox "All Done!"
    
    End Sub
    but I get the error on the line
    Margin = objAccess.Run(CIPdecision, Range(Coststrletter & i), Range(ICstrletter & i), Range(Packstrletter & i))
    any help is greatly appreciated!
    Last edited by DKY; 07-31-2009 at 01:54 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Application-defined or object-defined error on one machine but not the other

    Hello DKY,

    The object you are trying to connect with isn't running.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    09-19-2004
    Posts
    252

    Re: Application-defined or object-defined error on one machine but not the other

    I'm an idiot. The Access file was opening in read only because of macro security settings.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1