我希望返回两行,但要么锁定行,所以当再次运行查询时,会返回两个不同的行,或者将值输入到字段中,这样就可以防止被调用的行。
所以代码我已经为我返回了两行但是我无法在 Access 2010 中找到一种方法来执行上述操作,任何帮助都将不胜感激。
SELECT TOP 2 Referrals_Checked.Alternative_ID, Referrals_Checked.Team,
Referrals_Checked.Checked_By, Referrals_Checked.Date_Time
FROM Referrals_Checked
WHERE (((Referrals_Checked.Checked_By) Is Null) AND (([FORMS]!
[Referrals_Checked]![Combo49])=[TEAM_Code]))
ORDER BY Rnd(Referrals_Checked.ID);
答案 0 :(得分:0)
在表格中添加日期字段:TimeStamp。
修改您的查询以排除那些记录了TimeStamp的记录:
WHERE
Referrals_Checked.Checked_By Is Null AND
Referrals_Checked.TimeStamp Is Null AND
[TEAM Code] = [FORMS]![Referrals_Checked]![Combo49]
然后使用更新查询在您希望选择两个新ID时更新它:
UPDATE Referrals_Checked
SET Referrals_Checked.TimeStamp = Now()
WHERE ID IN (<SQL of your select query>)
然后选择你的两个加盖记录:
SELECT TOP 2
Referrals_Checked.Alternative_ID,
Referrals_Checked.Team,
Referrals_Checked.Checked_By,
Referrals_Checked.Date_Time
FROM
Referrals_Checked
ORDER BY
Referrals_Checked.ID Desc;