Microsoft Access 2010 filtering data based on tempvar

谁都会走 提交于 2019-12-11 07:54:01

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/27186465/microsoft-access-2010-filtering-data-based-on-tempvar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!