hi,
i have a query that returned a record ( a winner ) i want to display these data on the screen the code is below.the first time the data is displayed but after the first time the function doesn't work.
Private Sub Command12_Click()
Dim strSQL As String
Dim rs As DAO.Recordset
strSQL = "SELECT BA_TEST_TBL.NAME, BA_TEST_TBL.FATHER_NAME, BA_TEST_TBL.FAM_NAME, REF FROM BA_TEST_TBL WHERE (((BA_TEST_TBL.REF)=(SELECT Int(count(*)*rnd + 1 ) FROM BA_TEST_TBL)) AND ((BA_TEST_TBL.Flag)=No))"
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
Me.REF = rs.Fields("REF").Value
Me.NAME = rs.Fields("NAME").Value
Me.FATHER_NAME = rs.Fields("FATHER_NAME").Value
Me.FAM_NAME = rs.Fields("FAM_NAME").Value
DoCmd.RunSQL "UPDATE BA_TEST_TBL SET FLAG = YES WHERE REF = Me.REF "
rst.Close
Set rst = Nothing
rs.Close
End Sub