Link to home
Start Free TrialLog in
Avatar of Sheils
SheilsFlag for Australia

asked on

error 4605

When I run the procedures attached below I get the following error:-
error 4605 this method or procedure is not available because some or all of the object does not refer to a table

The error general occur when there is more than 8 rows required in the table. However, when I run it in debug mode it generate every row without any problem. I also tried it on a computer at work and it worked fine. Think that it may have something to do with my computer speed I will also provide its spec: -Windows 7 Ultimate Processor: Intel(R) Core(TM)i5-3470 CPU @ 3.20Hz 3.20Hz, Installed memory(RAM)8GB (7.70 GB usable), 64-bit Operating system.

The code that I am trying to run is as follows:
Public Function InsertSingleConsignementInfo(lngConsignmentID As Long, lngMovementID As Long)

'Insert single merge field
'-------------------------

'Consignee
lngEntityNameID = DLookup("fldconsigneeid", "tblConsignments", "fldconsignmentid=" & lngConsignmentID)
strConsignee = Nz(DLookup("fldothernames", "tbl_lkpEntityNames", "fldEntityID=" & lngEntityNameID), "")
strConsignee = strConsignee & " " & Nz(DLookup("fldsurname", "tbl_lkpEntityNames", "fldEntityID=" & lngEntityNameID), "")


objApp.ActiveDocument.Bookmarks("Consignee").Select
objApp.Selection.Text = strConsignee

'Movement

strMovement = DLookup("fldMovementdescription", "qryMovement", "fldMovementid=" & lngMovementID)
objApp.ActiveDocument.Bookmarks("Movement").Select
objApp.Selection.Text = strMovement

'Sender

lngEntityNameID = Nz(DLookup("fldSenderID", "tblConsignments", "fldconsignmentid=" & lngConsignmentID), 0)

If lngEntityNameID <> 0 Then

    strSender = Nz(DLookup("fldothernames", "tbl_lkpEntityNames", "fldEntityID=" & lngConsigneeID), "")
    strSender = strSender & " " & Nz(DLookup("fldsurname", "tbl_lkpEntityNames", "fldEntityID=" & lngConsigneeID), "")
    
    objApp.ActiveDocument.Bookmarks("Sender").Select
    objApp.Selection.Text = strSender

End If
'Merge List of good in the goods table
'-------------------------------------

strSQL = "Select * from TblGoods where fldConsignmentID=" & lngConsignmentID

setADODBReference

Rst.Open strSQL

i = 1

Do Until Rst.EOF
    If i = 1 Then
     
        'Add data to the first row to the table (the "empty" row)
        '--------------------------------------------------------
        'Quantity
        
        strQuantity = Nz(Rst!fldPackaging, "")
        strQuantity = strQuantity & " " & Nz(DLookup("fldUnits", "tbl_lkpUnits", "fldUnitID=" & Nz(Rst!fldPackageUnit, 0)), "")
        
        objApp.ActiveDocument.Bookmarks("Quantity").Select
        objApp.Selection.Text = strQuantity
        
        'Goods
        
        strGoods = Nz(DLookup("fldGoodsType", "tbl_lkpGoodsType", "fldGoodsTypeID=" & Rst!fldGoodsTypeId), "")
        
        objApp.ActiveDocument.Bookmarks("Goods").Select
        objApp.Selection.Text = strGoods
        
        'Length
        
        strLength = Nz(Rst!fldLength, "")
       
        objApp.ActiveDocument.Bookmarks("Length").Select
        objApp.Selection.Text = strLength
        
        
        'Tonnage
        strTonnage = Nz(Rst!fldTonnage, "")
       
        objApp.ActiveDocument.Bookmarks("Tonnage").Select
        objApp.Selection.Text = strTonnage
            
    Else
    
        'Create new row
        objApp.Selection.InsertRowsBelow
        objApp.Selection.MoveUp
        objApp.Selection.MoveDown
         
        'Insert Bookmarks in the new row
        
        AddBookmark "Quantity", i
        AddBookmark "Goods", i
        AddBookmark "Length", i
        AddBookmark "Tonnage", i
   
        'Add data to the new row
        
        'Quantity
        
        strQuantity = Nz(Rst!fldPackaging, "")
        strQuantity = strQuantity & " " & Nz(DLookup("fldUnits", "tbl_lkpUnits", "fldUnitID=" & Nz(Rst!fldPackageUnit, 0)), "")
        
        objApp.ActiveDocument.Bookmarks("Quantity" & i).Select
        objApp.Selection.Text = strQuantity
        
        
        'Goods
        
        strGoods = Nz(DLookup("fldGoodsType", "tbl_lkpGoodsType", "fldGoodsTypeID=" & Nz(Rst!fldGoodsTypeId, 0)), "")
        
        objApp.ActiveDocument.Bookmarks("Goods" & i).Select
        objApp.Selection.Text = strGoods
        
        
        'Length
        
        strLength = Nz(Rst!fldLength, "")
        
        objApp.ActiveDocument.Bookmarks("Length" & i).Select
        objApp.Selection.Text = strLength
        
        'Tonnage
        
        strTonnage = Nz(Rst!fldTonnage, "")
        
        objApp.ActiveDocument.Bookmarks("Tonnage" & i).Select
        objApp.Selection.Text = strTonnage
     
    End If
        
    i = i + 1

    Rst.MoveNext
Loop

Rst.Close

End Function

Private Sub AddBookmark(strBookmark As String, i)

objApp.ActiveDocument.Bookmarks.Add name:=strBookmark & i
objApp.Selection.MoveRight

End Sub

Open in new window


I hope that someone can point me in the right direction
Avatar of TheNautican
TheNautican

Firstly, I'd hit Alt+F11 and then click Debug then compile <nameofyourdatabase> and see what lines come back bad. If everything makes it past compile, then debug that procedure line at a time and see what pops.

Regards,
-Naut
Avatar of Gozreh
Which version office do you have ?
is the word file opened readonly ?
Avatar of Sheils

ASKER

TheNautican,

It passes compile. Debugging line by line does not pick it up. It generate all the rows and insert the data in the word document as intended. As I mention the error only occurs on my home computer. It works fine on my work computer. Problem is that I am designing it for someone to use on multiple computers so I have to be sure that it will work all the time.

Gozreh

I am using office 2007. Word opens normally as far as I know.
ASKER CERTIFIED SOLUTION
Avatar of jkaios
jkaios
Flag of Marshall Islands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sheils

ASKER

Thank jkois

I will go through the articles that you have proposed and get back later.

I tried the code on a client computer with only 500MB ram and it worked fine. So it is not a memory issue. I am inclined to agree that it is a security issue. But it will be good to find out exactly what so that I am able to fix it if it happens on another computer.

Cheers