Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2011
    Location
    Indianapolis, IN, USA
    Posts
    41

    Unanswered: Moving to the bottom of a continuous form

    I have two forms which are similar but different enough to justify separate forms. They are both continuous forms.
    The first form, frmAcctDisplay, is based on a variable strSQL which I set as the record source property for the form after getting a user choice from a combo box. I open a DAO recordset based on strSQL then I store the record count in variable intRecCnt. I update the records (a running balance field). I close the recordset then set the recordset type property to 2 so that it can’t be edited.
    I compute an offset by subtracting 18 (the approximate number of lines on the form) from the record count (intRecCnt). Then I have code which moves to the last record in the form then, moves back 18 records and displays the 18th record from the last record at the top of the display. This puts the last record at the bottom of the form then I select the last record.
    The above works great. It does exactly what I want it to do.

    I tried to use this idea on the second form, frmTransDisplay, but I keep getting an error of “Gotorecord is not available at this time.” This form is based on the same table but uses all the records in the table. A query is used to eliminate some fields and order the records properly. This query is used as the record source property for the form (no need for SQL in the code). The form opens exactly as I want except, of course, the oldest records are at the top. If I simply move to the last record, the last record will be displayed at the top of the display and the rest of the form will be blank. I have no need to open a recordset to update anything so in the Load event, I opened a recordset and moved to the last record to get the record count which I store in intRecCnt. Then I close the recordset. Next, I have the same code as the other form to compute an offset by subtracting 18 (the approximate number of lines on the form) from the record count (intRecCnt). Then I have code which moves to the last record in the form then, moves back 18 records and displays the 18th record from the last record at the top of the display. I keep getting the error message “Gotorecord is not available at this time.”
    Can anyone explain why this doesn’t work? I suspect it has something to do with the fact that the form isn’t completely loaded but I’m not sure. Later, I am going to try putting a command button on the form to trigger the code in an on click event but don’t have the time to experiment with it now.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You should try:
    Code:
    Dim rst as DAO.RecordSet
    
    Set rst = Me.RecordSetClone
    rst.MoveLast
    Me.Bookmark = rst.Bookmark
    rst.Close
    Set rst = Nothing
    Have a nice day!

Posting Permissions

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