Solved

MS Access code help

Posted on 2011-03-20
6
227 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
Comment Utility
try change:

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


to:

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

Expert Comment

by:Ryan Chong
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:Blueice13085
Comment Utility
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
Comment Utility
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
Comment Utility
Figured out on my own, but thanks for the help
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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.

763 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