Solved

MS Access code help

Posted on 2011-03-20
6
254 Views
Last Modified: 2012-05-11
here is the code i have that i need some help with. i want to open a word doc using on click, but i want the path to be stored in a table for change purposes

   
 Dim oApp As Object
    Dim strDocName As String
   
   strDocName = [b]DLookup("TowAwayFormLocation", "tblCompanyInformation", "CompanyID" = 1)[/b]

   Set oApp = CreateObject("Word.Application")
   oApp.Visible = True
   oApp.Documents.Open strDocName

Open in new window


the above code give me a run-time error 13 type mismatch in the table u see the Dlookup the field TowAwayFormlocation=C:\Quick Logs\Data\Forms\TowAwayForm.doc

if i use this code below it works fine.
 
 Dim oApp As Object
    Dim strDocName As String
   
     strDocName = C:\Quick Logs\Data\Forms\TowAwayForm = " & ".doc"

   Set oApp = CreateObject("Word.Application")
   oApp.Visible = True
   oApp.Documents.Open strDocName

Open in new window

0
Comment
Question by:Blueice13085
  • 4
  • 2
6 Comments
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 35177628
try change:

strDocName = DLookup("TowAwayFormLocation", "tblCompanyInformation", "CompanyID" = 1)


to:

strDocName = DLookup("TowAwayFormLocation", "tblCompanyInformation", "CompanyID" = 1)
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 35177630
I mean:

try change:

strDocName =
[b]DLookup("TowAwayFormLocation", "tblCompanyInformation", "CompanyID" = 1)[/b]

Open in new window



to:

strDocName = DLookup("TowAwayFormLocation", "tblCompanyInformation", "CompanyID" = 1)
0
 

Author Comment

by:Blueice13085
ID: 35177647
ops the [ / b ]was not ment to be there i was trying to make it bold what i had was


strDocName = DLookup("TowAwayFormLocation", "tblCompanyInformation", "CompanyID" = 1)
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:Blueice13085
ID: 35177650
this works fine
strDocName = "C:\Quick Logs\Data\Forms\TowAwayForm.doc"

but again i want that to be in the table! so it could be changed location
0
 

Accepted Solution

by:
Blueice13085 earned 0 total points
ID: 35177667
Dim oApp As Object
    Dim strDocName As String
   
   strDocName = DLookup("TowAwayFormLocation", "tblCompanyInformation", "[CompanyID] = 1")
   
   Set oApp = CreateObject("Word.Application")
   oApp.Visible = True
   oApp.Documents.Open strDocName

Open in new window


this works, but thanks for the help
0
 

Author Closing Comment

by:Blueice13085
ID: 35213345
Figured out on my own, but thanks for the help
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 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