Go to previous record

usr123

Registered User.
Local time
Today, 11:55
Joined
Jan 26, 2010
Messages
31
Hello,

I am working with access front end. I have got a form connected to Sql,it saves data in the database. Now i would like to pull data back from the database. There are a few buttons on the form,like previous,next,first and last. If form is empty and user click on previous button,then it should pull up the last record enterd in the database(according to the max id in the table),and when user keeps clicking it,it should pull back previous record one by one and so on.

Any suggestions how to do it?
 
This is what i am doing. When pointer reaches to the highlighted line, it comes up with the error: Run tim error:3061. Too few parameters, expected '1'
Any ideas on how to resolve it.
Code:
 Dim db As Database
      Dim rs As Recordset
      Dim strSQL As String
    Set db = CurrentDb()
   
    strSQL = "Select * from dbo_fin_ldg where "
    strSQL = strSQL & "[ID] IN (Select Max(ID) from dbo_fin_ldg)"
      
  [B]  Set rs = db.OpenRecordset(strSQL, DB_OPEN_DYNASET)
[/B]   
    rs.Close
    db.Close
    Set rs = Nothing
    Set db = Nothing

Thanks in advance!!
 
Here is another problem or apart of the previous one:

Filed value i am trying to select is identity. It works fine if i say "Select * from table."

But i want to select the last record in the table and for that i need Max(ID), if i get Max(ID) then i can pull the whole record.

Can anybody suggest me how to select the Max(ID) which is identity column from the table.....
 
figured it out, it was my database connection which was not reflecting the current database. Above code works just fine.
 

Users who are viewing this thread

Back
Top Bottom