Access 2013 Web App - multi value lookup

为君一笑 提交于 2019-12-25 04:07:45

问题


I'm creating a personal Access 2013 Web App on Sharepoint. I want to make a form for a table that will lookup an ID number based on multiple criteria. The table describes projects with some fields, we'll call them location, category, and units.

relating_table:
id    location    category       units
1     france      maintenance    hours

then my project table would have

id    fk_id    teamid     whatever
1     1        x          y
2     1        z          a

I want to set up my form so the user can choose "france" "maintenance" and "hours" and the form will know to input 1 for the "fk_id"

Most things I find on Google are for client-based Access databases. I tried to make the web app do a query through macros or something, but I can't find anywhere to type in SQL statements, which is very frustrating.

edit* my terminology may be incorrect regarding 'multivalue lookup'. I definitely do NOT want to store multiple values in a single field. I want to return a single value based on multiple criteria.


回答1:


If I understand your question correctly, then in a desktop database, you would make the rowsource for a combobox be 'relating_table', with id as the bound column, and display all three columns location, category, and units.

That solution doesn't work in web apps because they don't support displaying multiple fields. If that is the case, then you can create a query (unfortunately you can't type in SQL for web apps, but the query designer is the same as the desktop database otherwise) that has the id field from relating_table, and then an expression which combines the other fields (e.g. [location] + "-" + [category] + "-" + [units]) to use as the display field for a combo.

If, on the other hand, you want people to be able to choose location/category/units independently, and then set fk_id in your projects table based on the matching entry in relating_table, the solutions is slightly more complicated.

1) You would add 3 controls that allow the user to specify the value to lookup for each field.
2) You create a data macro that takes those values as parameters, does a LookupRecord in relating_table to find the corresponding record (assuming there is one), then set the return value for the macro to relating_table.id.
3) Create an AfterUpdate macro for the controls that allow the user to specify the values to lookup that invokes the data macro from #2, passing in the values from the controls as parameters, and then setting the fk_id field using the return value from the macro.



来源:https://stackoverflow.com/questions/27681269/access-2013-web-app-multi-value-lookup

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