Solved

error 4605

Posted on 2014-02-13
5
524 Views
Last Modified: 2014-03-06
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
0
Comment
Question by:Sheils
5 Comments
 
LVL 8

Expert Comment

by:TheNautican
ID: 39857330
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
0
 
LVL 10

Expert Comment

by:Gozreh
ID: 39857331
Which version office do you have ?
is the word file opened readonly ?
0
 
LVL 16

Author Comment

by:Sheils
ID: 39857442
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.
0
 
LVL 12

Accepted Solution

by:
jkaios earned 500 total points
ID: 39865892
It works fine on my work computer.

The problem could be simply configuration/security settings in which your home computer might have disabled the feature in Office 2007 while the computer in your office has it enabled.

Or maybe your home computer has not been updated with the latest service pack.

See if this can help:
https://support.microsoft.com/kb/248644

Or this:
http://support.microsoft.com/kb/813983

Or this:
http://answers.microsoft.com/en-us/office/forum/office_2013_release-word/run-time-error-4605-in-word-2013-no-information/1ca02c04-5cea-484e-bd23-f4d18183c1b2
0
 
LVL 16

Author Comment

by:Sheils
ID: 39866669
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question