使用表格按钮打开第二个表单,使用第一个表单中显示的数据 [英] Opening a 2nd form with form button using data displayed in first form

查看:108
本文介绍了使用表格按钮打开第二个表单,使用第一个表单中显示的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个访问数据库并创建了两个表单。第一个表单按库存编号查找资产,并显示资产分配给的学生。第二个表单显示学生和分配给他们的所有资产。有时我只有资产信息,并希望能够查找学生在第二个表格上的所有设备。这两种表格目前都使用组合框来选择资产记录或学生记录,具体取决于您所处的形式。我遇到的问题是学生表格需要填写组合框才能显示记录,所以我不能只创建一个表单按钮来调用特定的记录,因为它只是给我一个空白表单,然后我可以手动填写组合框值。我想自动选择那部分内容。组合框包含最后,FIRST格式的学生姓名以及学生姓名,以便在他们具有相同名称时轻松选择正确的学生。

我正在使用MS Access for Office 365 v16 64- Windows 10上的位。

Hi,

I have an access database and created two forms. The first form looks up Assets by inventory number and shows the student the assets are assigned to. The second form shows the student and all assets that are assigned to them. Sometimes I only have the asset info and want to be able to lookup all of the equipment the student has on the second form. Both forms currently use a Combo box for selecting the asset record or the student record depending on which form you are in. The problem I am having is that the student form requires the Combo Box to be filled in before it will show a record so I cannot just create a form button to call a specific record as it just gives me a blank form which I can then manually fill in the Combo Box value. I want to automate that part of the selection. The combo box contains the student name in LAST, FIRST format as well as the STUDENT NUMBER to ease selecting the correct student when they have the same name.
I am using MS Access for Office 365 v16 64-bit on Windows 10.

推荐答案

当新成员小心谨慎地发布问题并且从根本上讲很有道理时,我确实喜欢它。


为了回答你的问题,我会说有很多可能性。对不起,但你有。
I do like it when new members post questions properly with care and that fundamentally make good sense.

To answer your question I would say that there are a number of possibilities. Sorry, but there you are.
  1. 如果表单已经打开,那么你可以应用过滤器或使用代码导航到正确的记录。
  2. 如果仅在从其他表单中选择所需项目时打开表单,则可以使用过滤器( WhereCondition 参数)打开表单或导航到所需记录一旦它被打开。

    有些人喜欢在打开表单时让 OpenArgs 属性中的信息通过,并让表单排序导航到所需的记录,但是其他人更愿意在打开表单的相同代码中处理此问题。
  3. 可能您有特殊的理由为此使用两个单独的表单,但如果没有,那么您可以选择使用请改为级联表单过滤。这对我来说似乎更直接,但我不知道你的项目,所以可能有充分的理由采取不同的方式。
  1. If the form is already open then you can either apply a filter or navigate to the correct record using code.
  2. If the form is opened only when you select the item you want from the other Form then you can either open it with a filter (WhereCondition parameter) or navigate to the required record once it''s been opened.
    Some people prefer to pass the info in the OpenArgs property when opening the Form and letting the Form sort out navigating to the required record, but others prefer to handle this in the same code that opens the Form.
  3. It may be that you have particular reasons for using two separate Forms for this, but if not then you may choose to manage it all with Cascaded Form Filtering instead. It seems more straightforward to me, but I don''t know your project so there may be good reasons for doing it differently.

如果你需要进一步帮助我们,请告诉我们。

Let us know if you need further help with any of these suggestions.


感谢NeoPa。

我浏览了你指出的许多选项,并且由于第二种形式需要进入ComboBox而被困住了。我在发布后不久意识到我正在根据选择填充文本字段,然后根据文本字段值填充表单。通过跳过ComboBox,我能够解决我的问题;

以原始形式设置TempVar然后从第一个调用第二个表单。

我然后设置我的第二个表单上的文本框到''On Load''事件中的临时值。然后我会自动收到正确的记录数据。


我会将你的答案标记为最佳答案。再次感谢。
Thanks NeoPa.
I looked through many of the options that you have indicated and was being stumped due to the second form requiring an entry into the ComboBox. I realized shortly after posting that I was populating a text field based on the selection and then the form was populating based on the text field value. By skipping the ComboBox I was able to resolve my problem by;
Setting a TempVar in the original form and then call the 2nd form from the first.
I then set my text box on the second form to my temp value in the ''On Load'' Event. I would then automatically receive the correct record data.

I will flag your answer as the best one. Thanks again.


您可能需要考虑使用 OpenArgs 参数。打开允许您将信息从调用者传递给被调用者的表单时,这是一个可用的选项。它最好使用 TempVar ,因为范围更合适(在它需要使数据库混乱之后它不会停留)。


除非您确实需要在第二个表单中的不同记录之间导航,否则我首选的解决方案是在打开时将其过滤到该记录。它涉及最少的代码,并且非常清楚你的代码在做什么。


所有这一切,显然取决于你如何玩它。我祝你万事如意,但我的主要愿望是确保所有寻求的人都能看到可能的解决方案。
You may want to consider using the OpenArgs parameter instead. This is an option available to you when opening a Form that allows you to pass information from the caller to the callee. It''s preferable to the use of a TempVar as the scope is more appropriate (It doesn''t hang around after it''s needed cluttering up the database).

My preferred solution, unless you actually need to navigate between different records from within the second Form, is to filter it to that one record when opening. It involves the least code and makes it very clear what your code is doing.

All that said, it''s obviously up to you how you play it. I wish you the best of course, but my main desire is to ensure the possible solutions are up and visible to all who seek.


这篇关于使用表格按钮打开第二个表单,使用第一个表单中显示的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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