Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2010
    Posts
    2

    how to display the record returned from a query on the fields?

    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

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    try to put me.refresh after values are changed"

    rst.Close
    Set rst = Nothing

    me.refresh
    rs.Close
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 10-23-2009, 05:03 PM
  2. Replies: 6
    Last Post: 09-25-2009, 12:40 PM
  3. Counting returned records in a query
    By johncob in forum Queries
    Replies: 0
    Last Post: 02-11-2009, 05:30 PM
  4. Query to Display Tables & Fields
    By foxerator in forum Queries
    Replies: 0
    Last Post: 04-24-2008, 09:57 AM
  5. Can't display fields correctly....
    By benjamin in forum Database Design
    Replies: 0
    Last Post: 05-17-2006, 03:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums