通过顺序的文本场访问vba-loop,如果不是空的,请执行

发布于 2025-02-12 10:13:24 字数 363 浏览 0 评论 0原文

我需要一些帮助来优化数据输入的访问表格。在我的表格上,我中有许多不同的字段是7个文本字段。我想循环通过其中的6个,我依次命名,如果它们不是空的,请做某事。我正在使用Access VBA

尝试在伪代码中显示:

for i = 1 to 6
    if hardness_measurement_i > 0 then
        <do something>
    else
        <do nothing>
    end if
next i

我的问题是制定了循环的这一部分:“ hardness_measurement_i”

是否有一个很好的方法可以依次遵循命名的表单字段?

I need some help to optimize an access form for data entry. On my form I have many different fields amongst them are 7 text fields. I would like to loop through 6 of these which I have named sequentially and do something if they are not empty. I am using access VBA

Tried to show in pseudo code:

for i = 1 to 6
    if hardness_measurement_i > 0 then
        <do something>
    else
        <do nothing>
    end if
next i

My problem is formulating this part of the loop: "hardness_measurement_i"

Is there a good way to loop through form fields named sequentially?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

っ左 2025-02-19 10:13:24

尝试使用Controls收集表单的属性来获取contol。

If Me.Controls("hardness_measurement_" & i).Value > 0 Then
    '...

要检查文本框是否为空,您可以调用isnull()方法传递控件的value

If IsNull(Me.Controls("hardness_measurement_" & i).Value) Then
    '...

Try to get the contol by name using the Controls collection property of the form.

If Me.Controls("hardness_measurement_" & i).Value > 0 Then
    '...

To check if the textbox is empty, you can call the IsNull() method passing the control's Value.

If IsNull(Me.Controls("hardness_measurement_" & i).Value) Then
    '...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文