Access 2007使用SetValue宏将日期添加到多个记录 [英] Access 2007 Use SetValue macro to add date to multiple records

查看:245
本文介绍了Access 2007使用SetValue宏将日期添加到多个记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,用户首先在主窗体中选择一个ID,然后该ID的所有测量记录都显示在子窗体中。我有一个命令按钮设置为运行SetValue宏,以将主窗体上的文本框中输入的日期应用到我的子窗体中的Date
列。目前,宏仅更新子窗体中选择的记录。有没有办法可以将这个宏应用到子窗体中的所有记录,其ID与主窗体中选定的ID匹配?

I have a form where the user first selects an ID in the main form, then all the measurement records for that ID appear in a subform. I have a command button set to run a SetValue macro to apply the date entered in a text box on the main form to the Date column in my subform. Currently, the macro only updates the record that is selected in the subform. Is there a way I can apply this macro to all records in the subform with an ID that matches the selected ID in the main form?

我是Forms的新手并不完全习惯使用VBA 。我尝试设置模块来运行IF语句,但我不认为我的语法是正确的:

I am new to Forms and not entirely comfortable using VBA. I tried setting a module to run an IF statement but I don't think my syntax was correct:

IF [Forms]![MainForm]![SubForm]![ID] = [Forms]![MainForm]![ID] THEN DoCmd.RunMacro(mcrSetDate)




推荐答案

您好,

您可以将焦点设置为子窗体,然后使用GoToRecord操作移动每个子窗体,然后设置日期。但是,如果所有记录都应该具有相同的日期,为什么不将日期存储在主表单上。

You might be able to set the focus to the subform and then use the GoToRecord action to move through each one and then set the date. However, if all records are supposed to have the same date, why not just store the date on the main form.

只是想一想......

Just a thought...


这篇关于Access 2007使用SetValue宏将日期添加到多个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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