[mso] Re: Word 2002: VB forms, combo boxes and merging with outside data!

  • From: Cathy.Evans@xxxxxxxxx
  • To: mso@xxxxxxxxxxxxx
  • Date: Wed, 14 Sep 2005 09:06:23 -0400

Wow, thank you, Dian, I'm checking the websites and lessons now, and will
be working this out.  If I get stuck, I'll let you know!  I don't know vba
enough to feel comfortable with 'fairly well', but am learning to take one
step at a time.  Thank you so much for the direction and links, Cathy



                                                                                
                                
                      "Dian D. Chapman"                                         
                                
                      <dian@xxxxxxxxxxxxx      To: <mso@xxxxxxxxxxxxx>          
                                
                      >                                                         
                                
                      Sent by:                 cc:                              
                                
                      mso-bounce@freelist                                       
                                
                      s.org                    Subject:  [mso] Re: Word 2002: 
VB forms, combo boxes and merging 
                      09/14/2005 01:14 AM         with outside data!            
                                
                      Please respond to                                         
                                
                      mso                                                       
                          ..... 
                                                                                
                                
                                                                                
                                




Hi Cathy...

This kind of stuff is what I do. Note...it's can be somewhat complex...but
also kinda easy once you get the hang of it.

What you need to do is use ADO, ActiveX Data Object to create a connection
to the database. You CAN create a dialog  box to capture the path
information using the File System Object (FSO) and then concatenate that
path info into the Connection String. This means the user can find the DB
anywhere and it'll work fine. But barring all that, yes, you can hard code
the DB.

Once you create the ADO connection from Word to the Access DB (or Excel or
SQL...or whatever), you then can run queries from Word into the DB to
capture a RecordSet...which is like a virtual query result. Once that is
created, you work with that RecordSet to pull information to populate your
form, document, fields...whatever. And you can also then do the
reverse...get info from Word and pass it back into the DB.

Just to show you what you CAN do...you can see several examples of projects
I've done like this on my solutions site here:
http://www.mousetrax.com/Consulting_Solutions.html

As for learning how to do it...I have a sample on my site to get you
started. Go to http://www.mousetrax.com/techpage.html#autoforms and scroll
down to the "Please fill out this form" series. Locate, read, download the
sample and review the VBA/ADO code for the # 5 article on Database
Connectivity.

Two other great resources to master how all this works is to get this book:
http://www.mousetrax.com/books.html#ado and also hit the W3C schools and
read the ADO lessons. You'll find the link to the W3C schools (World Wide
Web free training) at this link:
http://www.mousetrax.com/Resources.html#learning

And, of course, you'll need to know VBA fairly well.

* You'll set the ADO reference
* Write the connection string to the DB using the Access Jet Engine OLEDB
Provider (driver) [Note the Access Provider is in my code. If you want to
use Excel, SQL or some other DB source, you can find the Connection
Provider
strings here: http://www.connectionstrings.com/
* You'll run an SQL query to create a RecordSet (RS)
* You'll then manipulate the RS as needed, such as putting it into an array
and then populating each item into the combo box using "Do Until RS.EOF"
(Do
until you hit the end of the record set.)
* When the user selects an item, you get the index for that item within
Word...OR...you can use the ID from that item in the DB...whichever you
prefer...and then do whatever you need with that info, such as put all that
info into the document...or previously capture all the info from the form
and add it to a current record in the DB or create a new record.

All this "add to/pull from" stuff with the DB is in the ADO for Dummies
book
that got me up and running with this stuff several years ago...in just a
few
days. But it's taken a couple years to master it all.

And...of course, if you prefer not to learn all this stuff...I can do the
work for you as a consultant or teach you how to do it. ;-)

Hope this helps...good luck!


Dian D. Chapman, Technical Consultant
Microsoft MVP, MOS Certified
Editor/TechTrax Ezine

Help Katrina's Homeless Animals: http://www.mousetrax.com/pets.html

Free Tutorials: http://www.mousetrax.com/techtrax
Optimize your business docs: http://www.mousetrax.com/consulting
Learn VBA the easy way: http://www.mousetrax.com/techcourses.html






-----------------------------------------------------------------------------------------------------
The information transmitted is intended only for the person
or entity to which it is addressed and may contain proprietary,  
business-confidential and/or privileged material.
If you are not the intended recipient of this message you 
are hereby notified that any use, review, retransmission, 
dissemination, distribution, reproduction or any action taken
in reliance upon this message is prohibited. If you received
this in error, please contact the sender and delete the 
material from any computer.  Any views expressed in this message
are those of the individual sender and may not necessarily reflect 
the views of the company.  
-------------------------------------------------------------------------------------------------------

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in 
the subject line.

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: