Following the instruction found here: Insert a datasheet into a form I get an error when trying to insert a query as a datasheet in an Access Project (SQL Server 2005 backend)
按照此处的说明:将数据表插入表单我尝试在Access项目中插入查询作为数据表时出错(SQL Server 2005后端)
The form name you entered doesn't follow Microsoft Office Access object-naming rules
您输入的表单名称不遵循Microsoft Office Access对象命名规则
I selected the view View.dbo.viewname
from the dropdown in 'Source Object' and the above error occurred as soon as I did that. If I take off View.dbo.viewname
, it saves, but then I can't see the datasheet data. I want to add the view as it contains subdatasheets.
我从“源对象”的下拉列表中选择了View.dbo.viewname视图,并且在我执行此操作后立即发生上述错误。如果我取消View.dbo.viewname,它会保存,但后来我看不到数据表数据。我想添加视图,因为它包含子数据表。
Wrapping it in brackets, e.g. [View.dbo.viewname]
or View[.]dbo[.]viewname
(as dots are apparently not allowed, although the link suggests otherwise) doesn't help
将其包装在括号中,例如[View.dbo.viewname]或View [。] dbo [。] viewname(显然不允许使用点,虽然链接暗示不是这样)但没有帮助
2 个解决方案
#1
It's a bit deceptive; "Query.foobar" is OK, but "Query.foo.bar" is not.
这有点欺骗性; “Query.foobar”没问题,但“Query.foo.bar”没有。
MS Access seems to be using that first portion as a way of deciding if your record source is a Query or Table, and the period (.) is a delimiter, and you seem to be limited to one. This is probably one of the reasons why it is disallowed in object names.
MS Access似乎使用第一部分作为决定您的记录源是查询还是表的方式,并且句点(。)是分隔符,并且您似乎仅限于一个。这可能是对象名称中不允许它的原因之一。
It looks like you are accessing the view directly instead of creating a link to the view in the tables tab/list (you shouldn't even be able to create a table/query named like that). Perhaps this is available in ms-access-2007, I'm not familiar enough with it.
看起来您正在直接访问视图,而不是在表选项卡/列表中创建指向视图的链接(您甚至不能创建一个这样的表/查询)。也许这在ms-access-2007中可用,我对它不够熟悉。
In any case, my solution would be to create a table link to View.dbo.viewname
and rename it (if MS Access doesn't do that for you by it self) to dbo_viewname
. This will let you set the data source to Table.dbo_viewname
.
在任何情况下,我的解决方案是创建一个到View.dbo.viewname的表链接,并将其重命名(如果MS Access不为您自己执行)到dbo_viewname。这样您就可以将数据源设置为Table.dbo_viewname。
Edit:
To create the table link,
编辑:要创建表格链接,
- go to the Tables tab/list on the database window
- right click in the list
- Select
link tables...
- Change
Files of Type
toODBC databases
(I assume you already have an ODBC connection set up. If not, how are you getting to your data?). - Switch to the
Machine Data Source
tab - Select your data source.
- Click OK
- Select the tables/views you want.
- Click OK
转到数据库窗口上的Tables选项卡/列表
右键单击列表
选择链接表...
将文件类型更改为ODBC数据库(我假设您已经设置了ODBC连接。如果没有,您如何获取数据?)。
切换到机器数据源选项卡
选择您的数据源。
选择所需的表/视图。
The links will show up in your tables tab/list as with arrows pointing at little green globe.
链接将显示在表格选项卡/列表中,箭头指向小绿色地球。
Don't type the data source in. Use the pull down, that will guarantee you are using the right syntax.
不要输入数据源。使用下拉,这将保证您使用正确的语法。
#2
Never managed to get it to work. Perhaps due to being an Access Project (ADP) rather than database (MDB). Had to resort to creating forms (with nested subforms) instead of datasheets to get what I wanted.
从来没有设法让它工作。也许是由于是一个Access Project(ADP)而不是数据库(MDB)。不得不求助于创建表单(使用嵌套的子表单)而不是数据表来获得我想要的东西。
Also, nested forms (two levels down) don't seem to work in Access 2007, but do in 2003, so had to go back to that.
此外,嵌套表单(两个级别)似乎在Access 2007中不起作用,但在2003年也是如此,所以不得不回到那个。
#1
It's a bit deceptive; "Query.foobar" is OK, but "Query.foo.bar" is not.
这有点欺骗性; “Query.foobar”没问题,但“Query.foo.bar”没有。
MS Access seems to be using that first portion as a way of deciding if your record source is a Query or Table, and the period (.) is a delimiter, and you seem to be limited to one. This is probably one of the reasons why it is disallowed in object names.
MS Access似乎使用第一部分作为决定您的记录源是查询还是表的方式,并且句点(。)是分隔符,并且您似乎仅限于一个。这可能是对象名称中不允许它的原因之一。
It looks like you are accessing the view directly instead of creating a link to the view in the tables tab/list (you shouldn't even be able to create a table/query named like that). Perhaps this is available in ms-access-2007, I'm not familiar enough with it.
看起来您正在直接访问视图,而不是在表选项卡/列表中创建指向视图的链接(您甚至不能创建一个这样的表/查询)。也许这在ms-access-2007中可用,我对它不够熟悉。
In any case, my solution would be to create a table link to View.dbo.viewname
and rename it (if MS Access doesn't do that for you by it self) to dbo_viewname
. This will let you set the data source to Table.dbo_viewname
.
在任何情况下,我的解决方案是创建一个到View.dbo.viewname的表链接,并将其重命名(如果MS Access不为您自己执行)到dbo_viewname。这样您就可以将数据源设置为Table.dbo_viewname。
Edit:
To create the table link,
编辑:要创建表格链接,
- go to the Tables tab/list on the database window
- right click in the list
- Select
link tables...
- Change
Files of Type
toODBC databases
(I assume you already have an ODBC connection set up. If not, how are you getting to your data?). - Switch to the
Machine Data Source
tab - Select your data source.
- Click OK
- Select the tables/views you want.
- Click OK
转到数据库窗口上的Tables选项卡/列表
右键单击列表
选择链接表...
将文件类型更改为ODBC数据库(我假设您已经设置了ODBC连接。如果没有,您如何获取数据?)。
切换到机器数据源选项卡
选择您的数据源。
选择所需的表/视图。
The links will show up in your tables tab/list as with arrows pointing at little green globe.
链接将显示在表格选项卡/列表中,箭头指向小绿色地球。
Don't type the data source in. Use the pull down, that will guarantee you are using the right syntax.
不要输入数据源。使用下拉,这将保证您使用正确的语法。
#2
Never managed to get it to work. Perhaps due to being an Access Project (ADP) rather than database (MDB). Had to resort to creating forms (with nested subforms) instead of datasheets to get what I wanted.
从来没有设法让它工作。也许是由于是一个Access Project(ADP)而不是数据库(MDB)。不得不求助于创建表单(使用嵌套的子表单)而不是数据表来获得我想要的东西。
Also, nested forms (two levels down) don't seem to work in Access 2007, but do in 2003, so had to go back to that.
此外,嵌套表单(两个级别)似乎在Access 2007中不起作用,但在2003年也是如此,所以不得不回到那个。