Solved

Access 2013 creates Word document

Posted on 2015-02-12
12
227 Views
Last Modified: 2016-02-11
I've inherited an Access application that keeps track of requests for dog licenses, liquor licenses, etc. for my city.  Unfortunately, I don't have any Access experience.  While the application itself is running fine, the Word documents it produces have a watermark/background that needs to be updated.
The Access application has both a front-end and a back-end.  When I open them in Alt-F11 mode, I can see code, but don't see any references to where the initial Word document/template can be found.  

Where do I look for it?
0
Comment
Question by:ITHastings
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 57
ID: 40606863
Do the Alt/F11 to get into VBA, then look for .doc

The code may be part of a form.

If you don't find it there, then the template used may be a value stored in a table as a field.   Look through the table names for anything like "Settings", "init", etc.

Jim.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40606886
if it is a template, you should look for .dot or .dotx or .dotm
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40606933
the Word documents it produces
So, it sounds like somewhere along the line, Word gets automated.
And probably as a mailmerge

Here's a snippet of how I get that started
        'open the mergedoc
        Dim oApp As Object
        Dim MlMrge As Object
        Set oApp = CreateObject(Class:="Word.Application")
        oApp.Visible = True
        
        'this will open a new document based on the path as a template.  Excellent
        'but it doesn't open it as a mail merge
        oApp.Documents.Add "c:\temp\Field Repair Welding Procedure Merge.doc"
        Set MlMrge = oApp.ActiveDocument.MailMerge
        With MlMrge
            'do the merge
            .OpenDataSource Name:="C:\temp\tblWeldProcData.xls", Connection:="DSN=Excel Files;DBQ=C:\temp\tblWeldProcData.xls;DriverId=1046;MaxBufferSize=2048;PageTimeout=5;", SQLStatement:="SELECT * FROM `tblWeldProcData`", SubType:=0 'wdMergeSubTypeOther
            .ViewMailMergeFieldCodes = 9999998 'wdToggle
            .Destination = 0 'wdSendToNewDocument
            .SuppressBlankLines = True
            With .DataSource
                .FirstRecord = 1 'wdDefaultFirstRecord
                .LastRecord = -16 'wdDefaultLastRecord
            End With
            .Execute (False)
        End With
        'save the merged doc
        oApp.ActiveDocument.SaveAs "c:\temp\RPR.doc"
        Dim Thedoc As Object
        'close the mergedoc
        For Each Thedoc In oApp.Documents
            If Thedoc.Name Like "document*" Then
                oApp.Documents(Thedoc.Name).Close False
            End If
        Next Thedoc
        oApp.Visible = True

Open in new window


Now, there's lots there, but the key bits are in bold
Set oApp = CreateObject(Class:="Word.Application")
Set MlMrge = oApp.ActiveDocument.MailMerge
oApp.ActiveDocument.SaveAs
For Each Thedoc In oApp.Documents

If you start looking for the bold bits in the entire VBA project, you should turn up the logic of how your app is working.

I've inherited an Access application...
Now, most developers think that storing files as attachments in tables is a lot like driving your car with your feet -- it can be done, but it's not a good idea.  Your predecessor may have done so to keep the app from being broken if someone moved/renamed/deleted/edited the source document, so it may be in a field in a table.  When you find the automation code driving Word, post it and we'll have a look.

Then the fun will begin.
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:ITHastings
ID: 40608183
The backend only has tables, there's no code.  When I do a search on the front-end, I don't see any .doc* files.  I bring up the find tool, have it look for ".doc*" and search in "Current Project", it doesn't find anything.

What else can I look for, or where else should I be looking?
0
 

Author Comment

by:ITHastings
ID: 40608213
There's lots of occurrences of code (based on license type) like this, but I don't know enough about Access to know what I'm missing.

Private Sub cmdPrintReceipt_Click()
On Error GoTo Err_cmdPrintReceipt_Click

    Dim stDocName As String

    stDocName = "rptDogLicenseReceipt"
    DoCmd.OpenReport stDocName, acPreview

Exit_cmdPrintReceipt_Click:
    Exit Sub

Err_cmdPrintReceipt_Click:
    MsgBox Err.Description
    Resume Exit_cmdPrintReceipt_Click
End Sub

Open in new window

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40608323
@ITHastings

di d you see my post at http:#a40606886 ?
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 500 total points
ID: 40608339
Perhaps we have a basic misunderstanding
'but I don't know enough about Access to know'
 stDocName = "rptDogLicenseReceipt"
    DoCmd.OpenReport stDocName, acPreview


This is code to open an MS Access report.
Reports can be previewed, and reports can be printed
Paper comes out of the printer

However
the Word documents it produces
that says something very different to an MS Access developer
Word documents are not MS Access reports; they can be printed and previewed but they are very different monsters.

Do you have a Word document or an MS Access report that you want to change?
That is the question!
Preview the document
Right-click.
Do you have a choice for Design View?
If you do, then you are dealing with an Access Report, and not a Word document
Is the dog license receipt one of the things that needs updating?
Because that is a report and has no relationship whatsoever with MS Word!
0
 

Author Comment

by:ITHastings
ID: 40608484
to Rey Obrero: Yes, I did a search through the code for all of the bolded strings, but found nothing.
0
 

Author Comment

by:ITHastings
ID: 40608497
to Nick67: Previewed the document and had a choice for Design View.  Thanks for your help.
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40608552
@ITHastings.
That's pretty terse!
So, you are dealing with a report
Were you able to get the changes you needed accomplished?
0
 

Author Closing Comment

by:ITHastings
ID: 40608871
Thanks for your patience.
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40608879
Glad to be of assistance!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now