访问:根据字段值更新一行值 [英] Access: update a row of values based on a field value

查看:51
本文介绍了访问:根据字段值更新一行值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1


HI


我有很多桌子的数据库。在第一个表中,我有一个名为status的字段。


[PHP]表1

idno名称状态

111 hjghf是

225 hjgjj没有

345 hgj是


其他桌子可能有不同字段的相同idno。

第二桌


idno工资费用

111 456 469

225 42

345 456 [/ PHP]


我想检查每个id no的状态,如果是,那么对于所有null和空白字段的所有表中的id号我想要将它们更新为111111.


我希望id为no 345的字段工资,其中第一个表中的状态为yes,由111111更新。像这样我需要循环为数据库中有很多表格


我正在寻找一个可以适应的示例vba代码。


谢谢

1

HI

i have database with many tables. In the first table i have a field called status.

[PHP]table 1
idno name status
111 hjghf yes
225 hjgjj no
345 hgj yes

other tables could have same idno with different fields.
2nd table

idno salary expense
111 456 469
225 42
345 456[/PHP]


I want to check the status for each id no and if it is yes then for that id number in all tables for all null and blank fields i want to update them as 111111.

I want the the field salary for id no 345 for which status is yes in first table to be updated by 111111. like this i need a loop as there are many tables in the database

I am looking for a sample vba code for this which i can adapt.

Thanks

推荐答案

从使用开始ga For CurrentDB中所有TableDef的每个循环。


其中,排除任何你不感兴趣的东西。


循环设置一个RecordSet(rs),其中包含链接到ID字段上[Table1]的每个表的SQL。

通过记录集处理,确保所有空字段都设置为111111。 (或111111)。使用rs.Edit& rs。更新任何更改以允许它们被应用。
Start by using a For Each loop for all the TableDefs in CurrentDB.

Within that, exclude any you''re not interested in.

Within the loop set up a RecordSet (rs) with SQL incorporating each table linked to [Table1] on the ID field.

Process through the recordset ensuring all empty fields are set to "111111" (or 111111). Use rs.Edit & rs.Update around any changes to allow them to be applied.


你好我这样开始

Hi I v started like this

展开 | 选择 | Wrap | 行号


我会开始为你看这个,但是看到错误信息也会非常有帮助。


为清楚起见 - 错误发生在代码中的第6/7行。
I will start looking at this for you, but it would be very helpful to see the error message too.

For clarity - the error occurs at lines #6/7 in your code.


这篇关于访问:根据字段值更新一行值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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