WHERE CAN I GET ANSWERS?

  • Thread starter Thread starter S. Jackson
  • Start date Start date
S

S. Jackson

Even after 3 years, I am still as green as grass trying to us MS access. I
know how to create tables, forms, queries, etc. What I seem to be having a
huge problem with is the fancy stuff. For instance, I have created a case
management db system for our office. It tracks all cases using several
different tables, i.e., AdminCases, Status, Hearings, Events, Discovery,
etc. The tables are all related via a field called "DHSNo." I also have a
separate table containing the names and addresses of all opposing attorneys
which is also connected in that when you pull up information regarding a
case using a form, it will tell you how the opposing counsel is and their
information. One of the things I'd like to do is have a button the user can
push that will open up a Word Document/letter to opposing counsel.

My question is: Where in the world do I get started learning how to write
the code in visual basic and/or how to write expressions. I do NOT find
that Microsoft help in Access easy to understand (when I'm even able to find
the information I want.) I would like something that gave me examples too.

S. Jackson
 
One of the things I'd like to do is have a button the user can
push that will open up a Word Document/letter to opposing counsel.

There are a couple of ways to go about this. My preference is to use OLE
automation to control Word and fill bookmarks in a template (.DOT file).
Some code that you can play with to familiarize yourself with the concepts
is found below.

First, create a Word template for your form letter. For this example, the
document name is C:\FormLetter.dot. In this template, you'll use the Insert
\ Bookmark command to create a bookmark at each location in the text where
you'll want to insert Access data. For this example, I'm using simple Name
and Address fields.

In Access, open any Module in design view. Then select Tools \ References
and make sure that you have a reference to the appropriate Word library.
Look for "Microsoft Word xx.x Object Library, where xx.x is theWord version
number. For this example, you will also need a reference to DAO.

' Behind a command button on a form, insert the following code.

BEGIN CODE SAMPLE:

Dim objWord As Object

' Open Microsoft Word using automation
Set objWord = New Word.Application

objWord.Documents.Add "c:\FormLetter.dot"
objWord.Visible = True

' The following code is generated from your Access form while it is
manipulating an instance of Word.
' So, while it looks somewhat like VBA, it's really Word VBA.

If objWord.ActiveDocument.Bookmarks.Exists("FirstName") = True Then
objWord.ActiveDocument.Bookmarks("FirstName").Range.Text = me!FirstName
End If

If objWord.ActiveDocument.Bookmarks.Exists("LastName") = True Then
objWord.ActiveDocument.Bookmarks("LastName").Range.Text = me!LastName
End If

' ... continue reading data from form and inserting into bookmark

END CODE SAMPLE

hth,
 
Back
Top