Solved

Access 2013 creates Word document

Posted on 2015-02-12
12
217 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 119

Expert Comment

by:Rey Obrero
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
 

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 119

Expert Comment

by:Rey Obrero
ID: 40608323
@ITHastings

di d you see my post at http:#a40606886 ?
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

760 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

21 Experts available now in Live!

Get 1:1 Help Now