通过复选框更新表的VBA代码? [英] VBA code to update tables through check box?

查看:88
本文介绍了通过复选框更新表的VBA代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我的数据库中有此表格。

https://lh4.googleusercontent.com/DZ...J3wWgo7mjU8rpA


我需要弄清楚怎么写复选框底部的按钮代码,以便在单击时...


1)选中的复选框将在主表中更新,从审计中删除表,并在副本表中保持不变


2)未选中的复选框仍将具有当前字段数据,并且不会对tblMaster进行更改但会还原$ t $ b附加背景信息:


- 我有一个用于更改查看从编辑锁定的tblMaster中的记录的表单。所有其他非管理员用户都使用此功能。


- 我有另一个表单可用于向其中一个记录提交更改请求(看起来像显示表单,除非它没有被锁定)。


然后将此信息移入tblMasterReplica(不在视图表单中显示)。它还显示在审计表中,以显示进行更改的人员,更改时间以及更改时间。它的变化和变化也是如此(新记录在表格的另一个之上)。


- 审计表格显示在更新表格中。屏幕截图中的列和tblMaster是Current中显示的内容。屏幕截图列。


- 屏幕截图只是表格中的一个标签,我使用标签控件,因为每条记录大约有65个字段。


我已经在这段代码中苦苦挣扎了很长一段时间,非常感谢任何额外的帮助。我是新手,所以我的代码背景非常有限。我非常感谢能得到的任何帮助。


感谢,


Rob

Hello,

I have this form in my database.

https://lh4.googleusercontent.com/DZ...J3wWgo7mjU8rpA

I need to figure out how to write the code for a button at the bottom of the checkboxes so that when clicked...

1) the check boxes that are selected will update in the master table, delete out of the audit table, and remain the same in the replica table

2) the check boxes that are not selected will still have the current field data and will not make a change to the tblMaster but will revert tblMasterReplica back to what it was prior to the change



Additional Background Info:

- I have a form to change view the records out of the tblMaster that is locked from editing. This is used by all the other non-Admin users.

- I have another form that can be used to submit a change request to one of the records (looks like the display form except it is not locked).

This information is then moved into tblMasterReplica (does not show in the view form). It is also displayed in the audit table to show who made the change, what time it was made, & what it was changed from and changed too (new record is on top of the other in table).

- The audit form is what is displayed on the "Updated" column in the screenshot and the tblMaster is what is displayed in the "Current" column of the screenshot.

- The screenshot is only one tab from the form, I used the tab control because there are about 65 fields for each record.


I have really been struggling with this code for quite a while and would really appreciate any additional help. I am very new to access so my background with code is extremely limited. I am very thankful for any of the help I can get.

With Appreciation,

Rob

推荐答案

你的链接不起作用。


我相信您需要的是更新查询。您只需要选中复选框的标准,然后您需要一个字段来识别哪些记录与两个表中的哪些记录对齐。


没有更详细的表格设计的信息,很难更具体。
Your link doesn''t work.

I believe that what you need is an update query. You would just have the criteria be that the check box is checked and then you would need a field that would identify which records lined up to which records in the two tables.

Without more detailed information of the table designs, it is hard to be more specific.


早安Rob:

如上所述,你的链接出现了403禁止。


建立在Seth指出的基础上......

我要做的是使用For Each和For Each。通过Select-Case检查类型或名称来逐步通过表单中的控件的步骤构建我的SQL字符串。或者,如果你只有两个或三个控件,你可以检查有问题的控件...只需要依赖于表单设计。


构建SQL后,将其用作dbs.execute UPDATE ...(SQL的其余部分)的基础


最后,这样您就可以获得所需的帮助,以及其他专家, mod,用户可以按照你今后要求的内容,以下内容真正必读:
如何提出好问题
发布指南


我也高度推荐以下网站为它有一个关于RDMS设计的很好的基础教程,因为大多数教科书确实做得不好...... 访问教程

特别值得注意的是页面< - b> - 注意给出的信息,表名,字段名,字段类型,键或索引等。 ..和用于呈现该数据的格式。你不需要一个花哨的网格表来做这个...只是一行一行的布局。在谈论表格等时需要同样的信息...


最恭敬的

-Z

你是什么意思在外面仍然是95 ......它是凌晨3点!> ......哦......小睡的时间:)
Good Morning Rob:
As noted, your link comes up as 403-forbidden.

Building on what Seth has pointed out...
What I would do is use a "For Each" statament to step thru the controls in the form either checking for type or name with a "Select-Case" to build my SQL string. Alternatively, if you only have two or three controls, you could just check the controls in question... just depends on the form design.

Once the SQL is built, use it as the basis for an "dbs.execute UPDATE...(remainder of SQL)"

Finally, so that you can really get the help you need, and the other experts, mod, and users can follow what you?re asking in the future, the following are really a must read:
How to ask good questions
Posting guidelines

I also highly recomend the following site as it has a great basic tutorial on RDMS design as most textbooks really do a poor job... A Tutorial for Access

Of particular note is tables page within the tutorial - notice the information that is given, the table name, the field name, the field type, key or index, etc... AND the format used to present that data. You don''t need a fancy gridded table to do this... just a line by line layout. This same information is needed when talking about forms etc...

Most Respectfully
-Z
What do you mean it''s still 95 outside... it''s 3am!>.... oh... time for a nap :)


再试一次点击链接错误出现后,出于某种原因似乎有效。此外,我正在努力通过教程,以便我能更好地理解答案并发布更好的答案,zmbd。如果问题写得不好,我很抱歉。


谢谢,


rob
Try clicking on the link a second time after the error comes up, for some reason that seems to work. Also, I am working hard to get through tutorials so I can better understand the answers and post better answers, zmbd. I apologize if the question was poorly written.

Thanks,

rob


这篇关于通过复选框更新表的VBA代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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