Microsoft Access 2010基于tempvar筛选数据 [英] Microsoft Access 2010 filtering data based on tempvar
问题描述
我需要这样做,因为每个登录的员工都只能看到产品表中给定的数据子集.在employee表中,我有一个带有字符串值的额外列,该字符串值是特定员工应查看的数据.
我有一个登录表单,单击登录后,将此字符串添加到tempvars集合中.我可以看到tempvar已添加到立即窗口中,如下所示:
?tempvars!tmpgrpdsc -> "IAMS"
我使用查询生成器选项来完成记录源属性,如下所示.
问题是什么都没有返回!
但是当我输入字符串"IAMS"时,我得到了返回的记录.
但是,我已经用另一个数据表完成了此工作,并且工作了,这里的tempvar保留了一个数字!见下文:
我缺少什么,或者有没有更好的方法可以根据登录信息过滤记录.谢谢
您显示的内容应该可以使用.
但是,您是否尝试过将条件更改为="""" & [Tempvars]![tmpGrdsc] & """"
此外,要确保您的tempvar实际上在查询期间包含数据,可以将其显示为一个字段,只是为了检查查询期间正返回的数据是什么:
SELECT Orders.*,
[Tempvars]![tmpGrdsc] AS TmpGrdsc
FROM Orders
i have a web database and im trying to filter a datasheet, based on the contents of a tempvar. Im trying to use the record source property of the datasheet to do this.
I need to do this because, every employee that logs in should only be able to see a given subset of data in the products table. In the employee table, i have an extra column with a string value which is the data that particular employee should see.
I have a login form that on clicking login, adds this string to the tempvars collection.I can see the tempvar has been added in the immediate window as shown below:
?tempvars!tmpgrpdsc -> "IAMS"
i use the query builder option to complete the record source property as shown below.
The problem is, nothing is returned !
But when i enter the string "IAMS", i get records returned.
However, i have done this with another datasheet and it has worked, the tempvar here held a number ! See below:
What am i missing or is there a better way to filter records based on the login. Thanks
What you showed should work.
However, have you tried to change the criteria to ="""" & [Tempvars]![tmpGrdsc] & """"
Also, to make sure that your tempvar is actually containing the data during the query, you could show it as a field, just to check exactly what data is being returned during the query:
SELECT Orders.*,
[Tempvars]![tmpGrdsc] AS TmpGrdsc
FROM Orders
这篇关于Microsoft Access 2010基于tempvar筛选数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!