Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Location
    Costa Rica
    Posts
    40

    Unhappy Unanswered: Save the result of Recordset into Variable

    need to display the result of a record using DAO recordset

    Table Registro has a field TODO which records the field NOW (current date)

    I would like to see the first data and the last data. If the first data is > than second data, then exit.

    If first data is < than second data, then delete first data

    Dim dbque As DAO.Database
    Dim strque
    Dim mano
    Dim Prim
    Dim Ult
    Dim rsque As Recordset
    Set dbque = CurrentDb()
    Set rsque = dbque.OpenRecordset("Registro")
    rsque.AddNew
    rsque("TODO") = Now
    rsque.Update
    Debug.Print " RecordCount = " & _
    rsque.RecordCount
    mano = rsque.RecordCount
    MsgBox mano
    With rsque
    .MoveFirst
    Prim = rsque.?????? (result of the first recordset)
    MsgBox Prim
    .MoveLast
    Ult = rsque.????? (result of the last recordset)
    If Prim > Ult then DoCmd.Quit acQuitSaveAll
    If Prim < Ult then ???????????? (delete first recordset)
    End With

    Need help where the ????? is located, please

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    To get the value of the TODO field, from rsque, use this:

    Prim = rsque!TODO
    ...
    Ult = rsque!TODO

    Then, to delete the first record:
    Docmd.Runsql "Delete * from registro where TODO = #" & PRIM & "#"

    I used the # symbol because the TODO field appears to be a date field.
    Inspiration Through Fermentation

  3. #3
    Join Date
    May 2003
    Location
    Costa Rica
    Posts
    40

    Perfect solution

    Perfect Solution. Thank you very much


    Originally posted by RedNeckGeek
    To get the value of the TODO field, from rsque, use this:

    Prim = rsque!TODO
    ...
    Ult = rsque!TODO

    Then, to delete the first record:
    Docmd.Runsql "Delete * from registro where TODO = #" & PRIM & "#"

    I used the # symbol because the TODO field appears to be a date field.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •