?
Solved

MS Access code help

Posted on 2011-03-20
6
Medium Priority
?
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 35177628
try change:

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


to:

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

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

764 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