Solved

Access Front / SQL Back - create view

Posted on 2014-07-27
7
76 Views
Last Modified: 2016-06-07
I have an access front end and a SQL back end.  

I have a MailMerge that uses a dynamically Query from the access database

I want to create a button to open the mailmerge document and run it, but so far, when I do, it tells me it cannot run it because the access database is locked.

I figure I can get around this by having the Access front end create a view and run the mailmerge against the view instead of the query.

But I don't know how to create a new view via VBA code in the access database.  Can anyone guide me?

Thanks!
0
Comment
Question by:Lee W, MVP
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 40223515
If you get a message that the database is locked, you're unlikely to be able to create a view. Can you select from the tables in question - if so, create a local Access query and use that. Alternately, create a pass-through-query - behaves like a view but you manage it from within Access. You can create the SQL locally (use SQL Server syntax), and set the sql in the same was as a dynamic query in Access.

I'd create a pass through query manually the first time (use properties to create the connection - accept the default connection) and save it - then just edit the sql on the fly from vba as you work.

Kelvin
0
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 40223549
Thing is, the Access database opens, I create the Query, then use VBA to open the Word doc.  Or open the word doc manually, But with an access database being accessed through ODBC, I figure that Word shouldn't have a problem opening the view.

I'm not familiar with Pass through Queries.  Will definitely check that out.  My current alternative is to have the query exported to an excel file and then have the word doc use that... not ideal in my opinion, but might be workable.
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 40223555
I must admit, that use the other way around and have Access open word and push the data into book marks in Word. It's years since I used Word as the driver, for much the reasons that you describe. I just found it too hard. I do try to keep the vba Object related rather than setting a reference to Word and then getting a customer with the wrong version of Word.


Kelvin
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 500 total points
ID: 40225203
Personally, I prefer to push data to Word document properties, but there are many ways to merge Access data to Word.  See my old Four Ways to Merge to Word sample database (it still works):

http://www.helenfeddema.com/Files/code24.zip

Even more ways are available in recent versions of Office, as covered in my more recent Working with Word ebook.
0
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 40225222
Thanks Helen, but I'm concerned - that's old stuff and the old stuff worked fine for this client... the DDE stuff... The query they had been using in word prompted for two user defined field values... that broke in 2007 or 2010... maybe earlier.  There's a kind of fix in a checkbox in General, but I'm trying to avoid that....
0
 
LVL 26

Expert Comment

by:MacroShadow
ID: 41640937
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Helen_Feddema (http:#a40225203)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

MacroShadow
Experts-Exchange Cleanup Volunteer
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 41641496
DDE is very, very old -- pre-VBA Automation.  Any code that uses DDE should definitely be upgraded.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

757 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

20 Experts available now in Live!

Get 1:1 Help Now