Solved

MS Access code help

Posted on 2011-03-20
6
238 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 49

Expert Comment

by:Ryan Chong
ID: 35177628
try change:

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


to:

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

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
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: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

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.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

920 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

14 Experts available now in Live!

Get 1:1 Help Now