如何使用表单上的按钮更改另一个表单/表上的值 [英] How to change a value on another form/table using a button on a form

查看:82
本文介绍了如何使用表单上的按钮更改另一个表单/表上的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该数据库旨在记录我的收藏中的所有Dvd,并在朋友拍摄时监控它们,有点像租赁系统。


有问题的表格/表格是DVD'(存放有关DVD的所有信息的表)和租赁(基本租赁细节,谁,何时等)和租赁细节(电影列表)


DVD表/表格有一个可用性复选框(是/否),说明DVD是否可用。


租赁表单有租赁详细信息作为子表单和我想要在主窗体上有一个按钮,当点击时,更改DVD表或表单上的可用性复选框,用于租赁详情子窗体中列出的DVD。


我想说可以使用If语句完成,但我不知道如何去做。我已尝试将此对象添加到子窗体上,并将控件源设置为DVD表。然后我在另一个字段的lostfocus事件上写了VBA来尝试更新这个字段但是我收到一个错误,说我不能写这个字段。


有什么想法吗?如果有人能提供帮助,我将不胜感激。它让我发疯了


谢谢


Groovygirl

The database is designed to record all Dvd''s in my collection and monitor them when friends take them, kind of like a rental system.

The tables/forms in question are DVD''s (a table storing all information about the Dvd''s) and rentals (the basic rental details, who, when etc) and rental details (the list of films)

The DVD table/form has an availability check box (yes/no) to state whether the dvd is avialable or not.

The Rentals form has Rental details as a subform and I would like to have a button on the main form that when clicked, changes the availability check box on the DVD table or form for the DVD''s listed in the rental details subform.

I want to say it can be done using an If statement but I don''t know how to go about it. I have tried adding this object onto the subform with the control source set to the DVD table. I then wrote VBA on the lostfocus event of another field to try and update this field but I got an error saying I can''t write to this field.

Any ideas? I would be more than grateful if anyone can help. It''s driving me crazy

Thanks

Groovygirl

推荐答案

我认为这是可能的,但如果你能发布到目前为止所有的代码(这只与这个过程相关)并且我们可以从那里开始,那将会很棒。


Pat
I think this is possible but it would be great if you could post all the code you have so far (that is related to just this process) and we can go from there.

Pat


我实际上已经把代码拿出来了,因为我对它感到非常沮丧,但我用宏取代了它。


我添加了子窗体的数量字段(对于DVD来说总是1),在LostFocus事件中添加了一个Setvalue宏,如下所示:


项目:[DVDs]![可用]

表达式:错误


这不起作用,现在我不知道。我想要它只是在单击按钮时取消选中该框。


我刚刚在耳边进行了操作,发现很难专注于任何事情: - (
I''ve actually taken the code out now as I got really frustrated with it but I replaced it with a macro.

I added a quantity field to the subform (which will always be 1 for a dvd) and on the LostFocus event added a Setvalue macro as follows:

Item: [DVDs]![Available]
Expression: False

This doesn''t work and now I have no idea. All I want it to do is uncheck the box when the button is clicked.

I have just had an operation on my ear and finding it very hard to concentrate on anything :-(


如果你正在考虑更新一个你的DVD表中的字段反映当前正在借出的一个字段(而不是由于任何其他原因而无法使用),那么我会重新考虑。这些信息应该在查询时从[出租明细]表中正确提取。这与使用规范化规则(请参阅规范化和表格结构如果这是一个项目,我很怀疑你会忽略数据库设计的基本原则而获得积分。


欢迎来到 Bytes !我希望你能用耳朵好好听。它可以迅速而充分地愈合(尽可能无痛地)。
If you are considering updating a field in your DVD table to reflect when one is currently on loan (as opposed to unavailable for any other reasons) then I would reconsider. This information should properly be extracted from the [Rental Details] table at time of enquiry. This is in accordance with the rules of Normalisation (See Normalisation and Table structures). If it''s a project, I doubt very much you''ll gain points for ignoring the fundamental principles of database design.

Welcome to Bytes! and I wish you well with your ear. May it heal quickly and fully (and as much as possible painlessly).


这篇关于如何使用表单上的按钮更改另一个表单/表上的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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