Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using queries in sql 2005 in an Access adp database

Posted on 2008-06-16
6
Medium Priority
?
187 Views
Last Modified: 2013-12-05
I have tha attached query that works fine in SQL, however i want to be able to use this query in an ADP file, however im not sure how to do it. I think i would have to use a stored procedure, however im not sure how to use these that well.

Could any one give me some help in getting this to work please.
SELECT tblcustomerdetails.Auto, tblcustomerdetails.[Date Recorded], tblcustomerdetails.NAME, tblcustomerdetails.[Trading As Name], tblcustomerdetails.SalesPerson, tblcustomerdetails.[Internal Status], tblterminaldetails.TID, tblterminaldetails.MID, tblmerchantinfo.[Previous Acq]
FROM ((tblcustomerdetails LEFT JOIN tblterminaldetails ON tblcustomerdetails.Auto = tblterminaldetails.Auto) LEFT JOIN tblratesandfees ON tblcustomerdetails.Auto = tblratesandfees.Auto) LEFT JOIN tblmerchantinfo ON tblcustomerdetails.Auto = tblmerchantinfo.Auto;

Open in new window

0
Comment
Question by:CaptainGiblets
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:orcic
ID: 21792229
You can create a view and use it in Access same way as you would a table.

create view v_tblcustomerdetails
 as
SELECT tblcustomerdetails.Auto, tblcustomerdetails.[Date Recorded], tblcustomerdetails.NAME, tblcustomerdetails.[Trading As Name], tblcustomerdetails.SalesPerson, tblcustomerdetails.[Internal Status], tblterminaldetails.TID, tblterminaldetails.MID, tblmerchantinfo.[Previous Acq]
FROM tblcustomerdetails LEFT JOIN tblterminaldetails ON tblcustomerdetails.Auto = tblterminaldetails
0
 
LVL 6

Author Comment

by:CaptainGiblets
ID: 21792344
ive created the view, however when i change data on one of the tables that populate the vie, will the view automatically be updated? or would i have to run something to get it to do that?
0
 
LVL 7

Expert Comment

by:orcic
ID: 21792387
view is actually a saved and compiled select statement so it will always show actual data from the related tables.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 6

Author Comment

by:CaptainGiblets
ID: 21792464
sorry just one more question. I think the name makes it obvious but ill ask anyway.

As it is only a view i take it it is read only? If you have a form bound to a view you cant change the data on it?
0
 
LVL 7

Accepted Solution

by:
orcic earned 2000 total points
ID: 21792968
It depends...
It is possible to make a view that would be updatable, but you have to follow certain rules.
http://msdn.microsoft.com/en-us/library/ms180800.aspx
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 21793118
The answer to your question depends on what you actually want to do with your query. In Access, the query is usually feeding the data to a form or report. If so, then all you need to do is specify your query as record source for the form or report, and it will work. There's no need to create a view or stored procedure, unless your query is very, very large (about 20 times larger than yours) and Access fails to interpret it - then you create the view to help Access.

Even if you need to only work with the query results directly, it's still good idea to create a form (wizard will create it for you in no time), rather than create view and open it from Access. Access will work much faster with the form than with the view, especially when the database has many objects.

Finally, the data being editable or read-only does not depend on whether it's a view or direct query; it mainly depends on all participating tables having primary keys, and those primary keys included in the query. Further, if it's a form, you can specify the unique table you are going to edit - if you open the view directly, Access won't know, so the same multi-table query may be read-only when opened as a view, and editable in the form.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
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 Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

782 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