473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Using DoCmd.OpenQuery on a query in a remote database

My clients have asked me to maintain a database that was developed in-
house. It's pretty good, considering the developer isn't a
"programmer".

The first thing they want me to do is to split it into a Front End/
Back End, which is very sensible. However, there are a number of ad
hoc queries that are required to be available to all users, which can
be edited, deleted or created "on the fly". The most sensible
solution would seem to be to store these in the Back End database, and
to get access to them thus:

Dim dbNew As DAO.Database
Dim qdfExisting As DAO.QueryDef

‘ Open the back end database
Set dbNew = DAO.Workspaces(0).OpenDatabase("C:\Projects\MyProj ect
\TestBackEnd.mdb")

‘ Open the query on the back end database
Set qdfExisting = dbNew.QueryDefs("qryGetCustomer")
In the existing code there is a function to edit these ad hoc queries
using the DoCmd.OpenQuery function.

DoCmd.OpenQuery "qryGetCustomer", acViewDesign

This works fine in the unsplit version. However, I can't seem to work
out how to pass a query on the remote database into this function.
Not unsurprisingly this doesn't work:

DoCmd.OpenQuery dbNew.QueryDefs("qryGetCustomer"), acViewDesign

Has anyone any ideas on how to solve this?

Thanks

Edward
Jun 27 '08 #1
10 7567
rkc
te********@hotmail.com wrote:
My clients have asked me to maintain a database that was developed in-
house. It's pretty good, considering the developer isn't a
"programmer".

The first thing they want me to do is to split it into a Front End/
Back End, which is very sensible. However, there are a number of ad
hoc queries that are required to be available to all users, which can
be edited, deleted or created "on the fly". The most sensible
solution would seem to be to store these in the Back End database, and
to get access to them thus:

Dim dbNew As DAO.Database
Dim qdfExisting As DAO.QueryDef

‘ Open the back end database
Set dbNew = DAO.Workspaces(0).OpenDatabase("C:\Projects\MyProj ect
\TestBackEnd.mdb")

‘ Open the query on the back end database
Set qdfExisting = dbNew.QueryDefs("qryGetCustomer")
In the existing code there is a function to edit these ad hoc queries
using the DoCmd.OpenQuery function.

DoCmd.OpenQuery "qryGetCustomer", acViewDesign

This works fine in the unsplit version. However, I can't seem to work
out how to pass a query on the remote database into this function.
Not unsurprisingly this doesn't work:

DoCmd.OpenQuery dbNew.QueryDefs("qryGetCustomer"), acViewDesign

Has anyone any ideas on how to solve this?
Think about this for a minute:

If you keep the editable queries in the backend .mdb file when they
are edited the edits will affect everyone using the application.

Jun 27 '08 #2
On 3 Jun, 13:56, rkc <r...@rkcny.yabba.dabba.do.comwrote:
[...]
Think about this for a minute:

If you keep the editable queries in the backend .mdb file when they
are edited the edits will affect everyone using the application
Which is exactly what's required.

Edward
Jun 27 '08 #3

"rkc" <rk*@rkcny.yabba.dabba.do.comwrote in message
news:48**********************@roadrunner.com...
te********@hotmail.com wrote:
My clients have asked me to maintain a database that was developed in-
house. It's pretty good, considering the developer isn't a
"programmer".

The first thing they want me to do is to split it into a Front End/
Back End, which is very sensible. However, there are a number of ad
hoc queries that are required to be available to all users, which can
be edited, deleted or created "on the fly". The most sensible
solution would seem to be to store these in the Back End database, and
to get access to them thus:

Dim dbNew As DAO.Database
Dim qdfExisting As DAO.QueryDef

‘ Open the back end database
Set dbNew = DAO.Workspaces(0).OpenDatabase("C:\Projects\MyProj ect
\TestBackEnd.mdb")

‘ Open the query on the back end database
Set qdfExisting = dbNew.QueryDefs("qryGetCustomer")
In the existing code there is a function to edit these ad hoc queries
using the DoCmd.OpenQuery function.

DoCmd.OpenQuery "qryGetCustomer", acViewDesign

This works fine in the unsplit version. However, I can't seem to work
out how to pass a query on the remote database into this function.
Not unsurprisingly this doesn't work:

DoCmd.OpenQuery dbNew.QueryDefs("qryGetCustomer"), acViewDesign

Has anyone any ideas on how to solve this?

Think about this for a minute:

If you keep the editable queries in the backend .mdb file when they
are edited the edits will affect everyone using the application.
You can only execute a query stored in the front-end so your code will need
to copy it from backend before it is executed.
Jun 27 '08 #4
<te********@hotmail.comwrote
>Think about this for a minute:

If you keep the editable queries in the backend .mdb file when they
are edited the edits will affect everyone using the application

Which is exactly what's required.
Seems unlikely to me... that is, if rkc modified a query for his own "ad
hoc" needs, then I'd be expected to have the same "ad hoc" needs next time I
used the application? In any case, you have to jump through some hoops to
store queries in the back end and execute them from the front end.

If these are queries that are part of the developed application, then they
should be created by the developers, distributed with each release of the
front end, and not changed by the users. The users, then, can use the
developed queries as the basis for their own "personal" queres, which they
store only in their own copy of the front end (or a separate front-end, as
the next release of the front-end will wipe out local modifications).

Few well-designed and well-implemented developed applications allow users to
make changes of the type you describe (or, in fact, use queries directly, at
all).

Larry Linson
Microsoft Office Access MVP

Jun 27 '08 #5
On 3 Jun, 14:49, "paii, Ron" <n...@no.comwrote:
[...]
You can only execute a query stored in the front-end so your code will need
to copy it from backend before it is executed.- Hide quoted text -
I'm thinking that this might be a non-starter, for the reason above.
Maybe what should be stored on the server is the SQL. Can anyone see
any problems with this?

Thanks

Edward

Jun 27 '08 #6
rkc
te********@hotmail.com wrote:
On 3 Jun, 14:49, "paii, Ron" <n...@no.comwrote:
[...]
>You can only execute a query stored in the front-end so your code will need
to copy it from backend before it is executed.- Hide quoted text -

I'm thinking that this might be a non-starter, for the reason above.
Maybe what should be stored on the server is the SQL. Can anyone see
any problems with this?
Now we're getting some where. Not only could you store the original SQL,
but you could store information about what it is used for.

And if it's really necessary, the latest user modification(s).
Jun 27 '08 #7

<te********@hotmail.comwrote in message
news:cc**********************************@m44g2000 hsc.googlegroups.com...
On 3 Jun, 14:49, "paii, Ron" <n...@no.comwrote:
[...]
You can only execute a query stored in the front-end so your code will
need
to copy it from backend before it is executed.- Hide quoted text -

I'm thinking that this might be a non-starter, for the reason above.
Maybe what should be stored on the server is the SQL. Can anyone see
any problems with this?

Thanks

Edward
Look at Stuart McCall's post, it shows how to copy the stored query from the
backend to the front-end. You will need to add code to do this each time a
user wants to run an ad-hoc query. You will also need to do the reverse each
time a user edits a ad-hoc query. This will be easy if you are using a form
to execute the query, otherwise supply a function to update at start-up
and/or shut-down. By the way, are you distributing a front-end for each user
or are they sharing?
Jun 27 '08 #8
On 3 Jun, 23:02, "Larry Daugherty"
<Larry.NoSpam.Daughe...@verizon.netwrote:
While lots of the lads and lasses who help other developers here are
wiser than I, few are also older. *Larry Linson is one such. *:-)
How old do you think I am? (I'm 51) What basis do you have for your
belief? And what has age got to do with anything?
To casually dismiss the suggestion that protecting the customer's data
is merely the behavior of a "purist" is to attempt thereby to
rationalize and justify irresponsible behavior. *I know that Larry
Linson and just about all of us who respond in these threads to help
other developers have years in the trenches. *We have all dealt with
customers large and small. *We have always had to do the best and most
responsible job we can. *Sometimes that's over client objections. *In
almost all cases there is some education of the client involved. *It's
not all one way, we learn from our clients too. *But, where the
protection of the client's data is concerned, we are the responsible
ones and what we have to say carries the day.
I completely disagree. We are there to do what our clients instruct
us to do. Sure, we should warn them if they plan to do something
really dumb, but in the end the decision is theirs, not ours. If you
ride roughshod over your client's stated requirements, then good luck
getting repeat business.
There are so many ways to achieve the same informational results for
the end users without allowing them design rights. *Queries are good
things. *Just about all of our forms and reports and many controls
depend on them. *But live queries do not belong in the hands of end
users. *
They do if that's what the client wants. I don't wish to offend, but
your attitude is highly patriarchal - in fact, you remind me of the
medical profession in the old days, who wouldn't trouble their clients
(patients) with the details of their diseases, because the poor dears
simply didn't have the mental capacity to understand.
That's only half a step removed from inviting them to muck
around directly in the tables (oh, that would be tougher to do since
your application is at least split....:-) *). *There are many ways to
use queries with list boxes and other controls to achieve the same
informational results without exposing the data to the users with no
protection at all. *The proper design would eliminate the need for
users to be involved at the level of SQL and would be significantly
more intuitive for the users.
I don't disagree with you. In an ideal world. But if you trouble to
read the thread properly, you'll find that I'm simply doing some small
amendments to allow an established application to run in a client/
server environment. There is no budget to give the client the ability
to create safe reports, ad hoc, as and when needed, via a super-duper
report builder. What they have now is, I admit, dumb and dirty, but
they're happy with it, and I want to get paid.
As to kowtowing to "Intimidating, Impressive, Authority", *don't*!
They need you or you or they wouldn't be paying you to be there. *In
the data domain of their application, *you* are the authority. *That's
one of the things you are being paid to provide. *You owe them your
best level thinking and performance. *
Which I've already given them, by alerting them to the potential risks
of allowing users to create queries ad hoc. My reservations are
documented. They're happy. Therefore, so am I.
By the way, as a "purist" my
customers have included the largest wireless telecom provider in the
US and the largest bank in the US. *There were many other customers,
large and small. *Usually there were several applications per customer
Similar issues arose in dealing with them. *The issues were discussed
and resolved. *In no instance of any application was the user invited
nor allowed into design mode. *Delivered application front ends were
MDE files.
But I'm not delivering something in that sense - this is a mature
application that, for reasons unrelated to current performance
(reasons of IT management), the clients require to be split into FE/
BE.
The mode of operation in the current application of your customer is
similar to the bliss and arrogance of NASA before the Challenger
disaster. *There were going to do what they wanted in a way that would
bring them the greatest praise and satisfaction. *To Hell with those
bothersome "purist" engineers who told them that attempting to launch
during extremely cold weather was to invite failure. *Hopefully, the
consequences would not be so drastic in this case.
That's rather over-egging the pudding, I think.
Notice that neither Larry Linson nor I suggested that "in a perfect
world I would do it this way ...." *In fact, the message is that if he
or I had the responsibility for the exact application that you do we
would provide the informational solution in a way that did not involve
the user getting at the design in any way. *Not with arrogance but
with information and by persuading and selling the better methods to
the customer.
Well, I'm a developer, not a salesman. If I had any talent in that
area I'd be selling for all I was worth, since I'd then stand a chance
of early retirement! If I were to stand my ground and refuse to do
the work on the grounds of a poor design, they would simply take their
business elsewhere. So I'm stuck with the current design.

And since you all are such experienced developers, care to tell me HOW
I can do what my clients have asked me to do, rather then WHY I should
NOT do it? That is, if you know. If it can't be done (opening a
remote query using DoCmd.OpenQuery) then I'll have to look at other
options, such as storing the SQL and creating local querydefs. That
method works in theory, but the problem is that the QBE window is
asynchronous, so capturing it being saved and then writing the revised
SQL to a table is a little more complex.

Edward
Jun 27 '08 #9
Just to assure myself that it was possible I just changed a Northwind
query from a new database, db1, using DoCmd etc.

On Jun 4, 3:55*am, teddysn...@hotmail.com wrote:
On 3 Jun, 23:02, "Larry Daugherty"

<Larry.NoSpam.Daughe...@verizon.netwrote:
While lots of the lads and lasses who help other developers here are
wiser than I, few are also older. *Larry Linson is one such. *:-)

How old do you think I am? *(I'm 51) What basis do you have for your
belief? *And what has age got to do with anything?
To casually dismiss the suggestion that protecting the customer's data
is merely the behavior of a "purist" is to attempt thereby to
rationalize and justify irresponsible behavior. *I know that Larry
Linson and just about all of us who respond in these threads to help
other developers have years in the trenches. *We have all dealt with
customers large and small. *We have always had to do the best and most
responsible job we can. *Sometimes that's over client objections. *In
almost all cases there is some education of the client involved. *It's
not all one way, we learn from our clients too. *But, where the
protection of the client's data is concerned, we are the responsible
ones and what we have to say carries the day.

I completely disagree. *We are there to do what our clients instruct
us to do. *Sure, we should warn them if they plan to do something
really dumb, but in the end the decision is theirs, not ours. *If you
ride roughshod over your client's stated requirements, then good luck
getting repeat business.
There are so many ways to achieve the same informational results for
the end users without allowing them design rights. *Queries are good
things. *Just about all of our forms and reports and many controls
depend on them. *But live queries do not belong in the hands of end
users. *

They do if that's what the client wants. *I don't wish to offend, but
your attitude is highly patriarchal - in fact, you remind me of the
medical profession in the old days, who wouldn't trouble their clients
(patients) with the details of their diseases, because the poor dears
simply didn't have the mental capacity to understand.
That's only half a step removed from inviting them to muck
around directly in the tables (oh, that would be tougher to do since
your application is at least split....:-) *). *There are many ways to
use queries with list boxes and other controls to achieve the same
informational results without exposing the data to the users with no
protection at all. *The proper design would eliminate the need for
users to be involved at the level of SQL and would be significantly
more intuitive for the users.

I don't disagree with you. *In an ideal world. *But if you trouble to
read the thread properly, you'll find that I'm simply doing some small
amendments to allow an established application to run in a client/
server environment. *There is no budget to give the client the ability
to create safe reports, ad hoc, as and when needed, via a super-duper
report builder. *What they have now is, I admit, dumb and dirty, but
they're happy with it, and I want to get paid.
As to kowtowing to "Intimidating, Impressive, Authority", *don't*!
They need you or you or they wouldn't be paying you to be there. *In
the data domain of their application, *you* are the authority. *That's
one of the things you are being paid to provide. *You owe them your
best level thinking and performance. *

Which I've already given them, by alerting them to the potential risks
of allowing users to create queries ad hoc. *My reservations are
documented. *They're happy. *Therefore, so am I.
By the way, as a "purist" my
customers have included the largest wireless telecom provider in the
US and the largest bank in the US. *There were many other customers,
large and small. *Usually there were several applications per customer
Similar issues arose in dealing with them. *The issues were discussed
and resolved. *In no instance of any application was the user invited
nor allowed into design mode. *Delivered application front ends were
MDE files.

But I'm not delivering something in that sense - this is a mature
application that, for reasons unrelated to current performance
(reasons of IT management), the clients require to be split into FE/
BE.
The mode of operation in the current application of your customer is
similar to the bliss and arrogance of NASA before the Challenger
disaster. *There were going to do what they wanted in a way that would
bring them the greatest praise and satisfaction. *To Hell with those
bothersome "purist" engineers who told them that attempting to launch
during extremely cold weather was to invite failure. *Hopefully, the
consequences would not be so drastic in this case.

That's rather over-egging the pudding, I think.
Notice that neither Larry Linson nor I suggested that "in a perfect
world I would do it this way ...." *In fact, the message is that if he
or I had the responsibility for the exact application that you do we
would provide the informational solution in a way that did not involve
the user getting at the design in any way. *Not with arrogance but
with information and by persuading and selling the better methods to
the customer.

Well, I'm a developer, not a salesman. *If I had any talent in that
area I'd be selling for all I was worth, since I'd then stand a chance
of early retirement! *If I were to stand my ground and refuse to do
the work on the grounds of a poor design, they would simply take their
business elsewhere. *So I'm stuck with the current design.

And since you all are such experienced developers, care to tell me HOW
I can do what my clients have asked me to do, rather then WHY I should
NOT do it? *That is, if you know. *If it can't be done (opening a
remote query using DoCmd.OpenQuery) then I'll have to look at other
options, such as storing the SQL and creating local querydefs. *That
method works in theory, but the problem is that the QBE window is
asynchronous, so capturing it being saved and then writing the revised
SQL to a table is a little more complex.

Edward
Jun 27 '08 #10
On Jun 4, 11:55*am, lyle fairfield <lyle.fairfi...@gmail.comwrote:
Just to assure myself that it was possible I just changed a Northwind
query from a new database, db1, using DoCmd etc.
I've entirely failed to be able to do that. Would you be so very kind
as to post the code? In other words, how do you reference the
Northwind query in your db1 database code?

Thanks

Edward
Jun 27 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Phil Sandler | last post by:
Hello, Quick, and possibly strange, question. I am doing some work testing the running time of some dynamic SQL statements on a remote machine. What I would like to do is execute the SQL on...
3
by: jj | last post by:
I've got a form button that fires off 3 queries but if the first query returns an error, I don't want the other two queries to happen. Example: first query runs an insert from a linked table but...
4
by: jstaggs39 | last post by:
I have a form that requires a start date and an end date as input for the parameters then runs the form which open queries which are designed to populate certain tables. As it stands now, i can...
2
by: Stu | last post by:
Hi, I've been working on trying to use a combo box to filter my records for a while now, and can't get it to work. Right now, I have SQL code written into IfThen statements on the afterupdate for...
11
by: DP | last post by:
hi, i have a films table and form. i have a txt field in teh form called txtSearch , and i;ve created a query with all the film table fields in it. how can i get the query to load up, wth the...
4
by: jpr | last post by:
Hello, I have created menu bars for my access application and now would like to transfer many pieces of code in modules so that they can run using macros. I beleive this is the only way I can...
5
by: alingsjtu | last post by:
Hello, every body. When execute dynamic generated multiple OPENQUERY statements (which linkes to DB2) in SQLServer, I always got SQL1040N The maximum number of applications is already connected...
1
by: glamster7 | last post by:
Ok I hope I can explain this properly. I am designing a hairdressing booking system database in a college environment. The thing I'm trying to do at the momemnt I'm a little lost with I have a...
10
by: Dean | last post by:
My client has a db I am working that uses temp tables. During an update procedure, I had the code If fTableExists(tempTblName) = True Then DoCmd.DeleteObject acTable, tempTblName Then I thought...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.