在远程数据库中的查询上使用DoCmd.OpenQuery [英] Using DoCmd.OpenQuery on a query in a remote database

查看:381
本文介绍了在远程数据库中的查询上使用DoCmd.OpenQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的客户要求我维护一个在
房子里开发的数据库。这是相当不错的,考虑到开发人员不是b $ b程序员。


他们要我做的第一件事就是拆分它进入前端/

后端,这是非常明智的。但是,所有用户都需要提供大量的b
hoc查询,这些查询可以即时编辑,删除或创建。 。最明智的

解决方案似乎是将这些存储在后端数据库中,并且

因此可以访问它们:


Dim dbNew作为DAO.Database

Dim qdfExisting as DAO.QueryDef


?打开后端数据库

设置dbNew = DAO.Workspaces(0).OpenDatabase(" C:\Projects \ MyProj ect

\ TestBackEnd.mdb" )


?在后端数据库上打开查询

设置qdfExisting = dbNew.QueryDefs(" qryGetCustomer")

在现有代码中,有一个编辑这些即席查询的功能

使用DoCmd.OpenQuery函数。


DoCmd.OpenQuery" qryGetCustomer",acViewDesign


这是有效的在非分裂版本中很好。但是,我似乎无法工作

如何将远程数据库上的查询传递给此函数。

毫不奇怪这不起作用:


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


有没有人想过如何解决这个问题?


谢谢


爱德华

解决方案

te ******** @ hotmail.com 写道:


我的客户要求我维护一个在
house开发的数据库。这是相当不错的,考虑到开发人员不是b $ b程序员。


他们要我做的第一件事就是拆分它进入前端/

后端,这是非常明智的。但是,所有用户都需要提供大量的b
hoc查询,这些查询可以即时编辑,删除或创建。 。最明智的

解决方案似乎是将这些存储在后端数据库中,并且

因此可以访问它们:


Dim dbNew作为DAO.Database

Dim qdfExisting as DAO.QueryDef


?打开后端数据库

设置dbNew = DAO.Workspaces(0).OpenDatabase(" C:\Projects \ MyProj ect

\ TestBackEnd.mdb" )


?在后端数据库上打开查询

设置qdfExisting = dbNew.QueryDefs(" qryGetCustomer")


在现有代码中有一个编辑功能这些即席查询

使用DoCmd.OpenQuery函数。

DoCmd.OpenQuery" qryGetCustomer",acViewDesign


这在未分割版本中工作正常。但是,我似乎无法工作

如何将远程数据库上的查询传递给此函数。

毫不奇怪这不起作用:


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


有没有人知道如何解决这个问题?



想想这一分钟:


如果你在后端.mdb文件中保留可编辑的查询编辑br />
编辑将影响使用该应用程序的每个人。


6月3日,13:56,rkc< r。 .. @ rkcny.yabba.dabba.do.comwrote:

[...]


想想这一分钟:


如果在编辑后端.mdb文件时保留可编辑查询

,则编辑将影响使用该应用程序的每个人


这正是所需要的。


Edward




" rkc" < rk*@rkcny.yabba.dabba.do.com写信息

news:48 ********************** @ roadrunner.com ...

te ******** @ hotmail.com 写道:


我的客户要求我维护一个在
house开发的数据库。这是相当不错的,考虑到开发人员不是b $ b程序员。


他们要我做的第一件事就是拆分它进入前端/

后端,这是非常明智的。但是,所有用户都需要提供大量的b
hoc查询,这些查询可以即时编辑,删除或创建。 。最明智的

解决方案似乎是将这些存储在后端数据库中,并且

因此可以访问它们:


Dim dbNew作为DAO.Database

Dim qdfExisting as DAO.QueryDef


?打开后端数据库

设置dbNew = DAO.Workspaces(0).OpenDatabase(" C:\Projects \ MyProj ect

\ TestBackEnd.mdb" )


?在后端数据库上打开查询

设置qdfExisting = dbNew.QueryDefs(" qryGetCustomer")

在现有代码中,有一个编辑这些即席查询的功能

使用DoCmd.OpenQuery函数。


DoCmd.OpenQuery" qryGetCustomer",acViewDesign


这是有效的在非分裂版本中很好。但是,我似乎无法工作

如何将远程数据库上的查询传递给此函数。

毫不奇怪这不起作用:


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


有没有人知道如何解决这个问题?



想一想这一点:


如果你在后端.mdb文件中保留可编辑的查询编辑br />
编辑将影响使用该应用程序的每个人。



您只能执行存储在前端的查询,因此您的代码将需要

才能在执行之前从后端复制它。


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

解决方案

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.


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



"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.


这篇关于在远程数据库中的查询上使用DoCmd.OpenQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆