Using VB to transfer Access (XP) forms data to word doc

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sycryc
    New Member
    • Jun 2008
    • 1

    Using VB to transfer Access (XP) forms data to word doc

    Here's my Q. I have a form in which users fill in text boxes and select checkboxes. After the form is completed, the user clicks the submit button which then transfers all to a word for editing, saving or emailing. My problem is trying get the checkboxes input to transfer to word and have the corresponding checkbox in word checked as well.

    Can anyone suggest a solution?

    Here is how I have been able to successfully transfer the text from the access form text field to a bookmark in the word doc.

    Code:
    Private Sub Option133_click()  
    Dim objWord As Word.Application    '
    Start Microsoft Word.    
    Set objWord = CreateObject("Word.Application")    
    With objWord        
    'Make the application visible.        
    .Visible = True       
     'Open the document.        
    .Documents.Add ("\AWARD.frm.dot")                
    'Move to each bookmark and insert text from the form.        
    .ActiveDocument.Bookmarks("Address1").Select        
    .Selection.Text = (CStr(Forms![frmPDocuments]![Address1]))        
    .ActiveDocument.Bookmarks("City").Select        
    .Selection.Text = (CStr(Forms![frmPDocuments]![City]))        
    .ActiveDocument.Bookmarks("State").Select        
    .Selection.Text = (CStr(Forms![frmDocuments]![State]))        
    .ActiveDocument.Bookmarks("Zip").Select        
    .Selection.Text = (CStr(Forms![frmPDocuments]![Zip Code]))
    End With
    End Sub
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi. Correct me if I'm misinterpreting here, but the only way I can see of doing what you ask (to have checkboxes in Access represented correctly as checkboxes in a Word document) would be to have checkboxes in the Word document and set or clear their values using VBA code to do so.

    The problem is that a checkbox is just the means for storing a boolean value (where -1 represents True/Yes/Ticked and 0 represents False/No/Not ticked). When the data is exported to Word it is the -1 or 0 which is transferred, not the graphical tickbox representation.

    In a Word document you should be able to use the extended characters from the Unicode character set of your current font to output special characters such as the square root symbol to simulate a tick (using the unicode version of the Chr function, ChrW to do so), or if you are outputting to a table column formatted in Wingdings say you should be able to output one of the graphic characters representing a ticked or unticked box.

    Other than that I can't think of how you could transfer a checkbox representation of a yes/no value from Access to Word.

    -Stewart

    Comment

    Working...