形式
从表中查询项的。例如,如果这是我的桌子:
ID | Type | Active | Leading | DaysBehind
1 A Yes Yes 0
2 A Yes No 20
3 A Yes No 40
4 B Yes Yes 0
5 B Yes No 30
6 C Yes Yes 0
然后是搜索(
)对于Type=A返回:
txtID | cmbType | cmbActive | cmbLeading | txtDaysBehind
1 A Yes Yes 0
2 A Yes No 20
3 A Yes No 40
我想写一个关于更改VBA代码的代码,这样当我将ID 1更改为Active=No时,就会发生以下情况:ID 1 Leading=No和ID 2 Leading=Yes(因为这是最短的时间)。
由于ID 1是我的当前记录,因此此代码非常简单:
cmbLeading = "No"
rs = CurrentDB.OpenRecordset("SELECT ID FROM table WHERE Type='A' AND Active='Yes' ORDER BY DaysBehind")
CurrentDb.Execute "UPDATE table SET table.Leading='Yes' WHERE table.ID=2"
它没有对表进行任何更改,我猜这是因为我在表单中打开了记录。我需要在表格上做更改吗?如果是,如何更改非当前记录?