Word Table saved as ActiveX in Access, how to display in Word

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pejo
    New Member
    • Jan 2010
    • 3

    Word Table saved as ActiveX in Access, how to display in Word

    I use Word and Access 2007 with a mail-merge OLE DB connection
    that works well with the linking of text fields, etc. (type customer and contact information)
    My problem is that I need to link into a formatted Word table stored in data type, ActiveX, Access to my Word document.
    When I try it says only "151C2E00" in the field, where the table would appear

    Someone who has solution!

    Code:
    Sub Foto()
        ActiveDocument.MailMerge.OpenDataSource Name:= _
            "\\vmware-host\Shared Folders\My Documents\Mina datakällor\Foto.accdb" _
            , ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
            AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
            WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
            Format:=wdOpenFormatAuto, Connection:= _
            "Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=\\vmware-host\Shared Folders\My Documents\Mina datakällor\Foto.accdb;Mode=Read;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Engine Type=6;Jet OLED" _
            , SQLStatement:="SELECT * FROM `FR_Kopplat_Till_Word_25`", SQLStatement1 _
            :="", SubType:=wdMergeSubTypeAccess
    End Sub
    Last edited by nico5038; Jan 24 '10, 06:30 PM. Reason: Added code tags
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    I have my doubts about the quotes in the SQL statement:
    Code:
    SQLStatement:="SELECT * FROM `FR_Kopplat_Till_Word_25`"
         try:
    SQLStatement:="SELECT * FROM 'FR_Kopplat_Till_Word_25'"
    Nic;o)

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      As Nico has said, it seem that you have worked on this within a document editor (like Word or Write) rather than in a text editor (EG. Notepad). Document editors often switch quote characters on you, for reasons that make sense in a document - but not in SQL. Never edit SQL in anything but a text editor.

      Further info - Quotes (') and Double-Quotes (") - Where and When to use them.

      Comment

      • Pejo
        New Member
        • Jan 2010
        • 3

        #4
        I've tried to change the quotes to " ' " instead but the only difference that the code "151C2E00" In the field, where the "word table" would appear, is empty.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32633

          #5
          Code:
          It's not the (")s you should worry about here.  It's the (`)s.
          I put that in the [CODE] tags to illustrate the characters more clearly.

          Comment

          • Pejo
            New Member
            • Jan 2010
            • 3

            #6
            Ok that was how I was doing, would not use " ' " but ( ' ) instead,
            I am learning all the time.
            Have you tried to do the same kind of access and have it work?

            Comment

            • nico5038
              Recognized Expert Specialist
              • Nov 2006
              • 3080

              #7
              It's hard to try for us, not having the same database and merge document.
              As the code has disappeared gives the impression that the statement is correct so the next step is to check or the query does return data.

              I would also check or the used ActiveX control is the only one in the document and that the fields are inline with the fields from the SELECT.

              It's always to be advised to use field names instead of the "*", as an addition of a field to the table could cause havoc...

              Nic;o)

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #8
                Originally posted by Pejo
                Ok that was how I was doing, would not use " ' " but ( ' ) instead
                I don't follow you. The code as posted has (`) embedded within the SQL where there should be ('). Are you saying you've changed those now and it uses just the (')s?

                Comment

                Working...