1

这就是我想要做的。单击 btnDraw 后,我希望 Access 运行查询 Test 并将结果带回字符串获胜者。然后在 lblWinner 中显示结果。

Private Sub btnDraw_Click()

Dim winner As String

winner = ???????

lblWinner.Caption = winner

End Sub

这是 TEST 查询的 SQL 代码:

SELECT TOP 1 [Goth Table].representative
FROM [Goth Table]
WHERE ((([Goth Table].[Would you like to be entered in the drawing])=Yes))
ORDER BY Rnd(Int(Now()*id)-Now()*id);

谢谢!

4

1 回答 1

0

尝试:

 Winner=
 currentdb.openrecordset("
 SELECT TOP 1 [Goth Table].representative
 FROM [Goth Table]
 WHERE [Goth Table].[Would you like to be entered in the drawing]=Yes
 ORDER BY Rnd(Int(Now()*id)-Now()*id);").fields(0)
 ")

我添加了一些换行符以提高可读性。您可能想要删除这些。我也很好奇你的 Order By 条款。这不是您问题的一部分,但是按随机数排序如何让您成为赢家?

于 2013-04-24T17:42:30.950 回答