Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Newbie
 
Join Date: Jun 2008
Posts: 1
#1: Jun 23 '08
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.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Option133_click()  
  2. Dim objWord As Word.Application    '
  3. Start Microsoft Word.    
  4. Set objWord = CreateObject("Word.Application")    
  5. With objWord        
  6. 'Make the application visible.        
  7. .Visible = True       
  8.  'Open the document.        
  9. .Documents.Add ("\AWARD.frm.dot")                
  10. 'Move to each bookmark and insert text from the form.        
  11. .ActiveDocument.Bookmarks("Address1").Select        
  12. .Selection.Text = (CStr(Forms![frmPDocuments]![Address1]))        
  13. .ActiveDocument.Bookmarks("City").Select        
  14. .Selection.Text = (CStr(Forms![frmPDocuments]![City]))        
  15. .ActiveDocument.Bookmarks("State").Select        
  16. .Selection.Text = (CStr(Forms![frmDocuments]![State]))        
  17. .ActiveDocument.Bookmarks("Zip").Select        
  18. .Selection.Text = (CStr(Forms![frmPDocuments]![Zip Code]))
  19. End With
  20. End Sub
  21.  
  22.  

Moderator
 
Join Date: Feb 2008
Location: Beauly, near Inverness, Scotland
Posts: 1,576
#2: Jun 27 '08

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


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
Reply


Similar Microsoft Access / VBA bytes