Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116

    Smile Unanswered: end of records then display control

    When I reach the end of a set of records, I want to set my form up to display certain controls. How can I do this?

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    In your form's OnCurrent property, put some code like this:

    Code:
    DIM rstForm AS DAO.RECORDSET
    SET rstForm = Me.RecordsetClone
    rstForm.Bookmark = Me.BookMark 'move to the same record
    rstForm.MoveNext 'move forward one record
    If rstForm.Eof Then
       'must be on last record  
       'display your controls
    End If
    Inspiration Through Fermentation

  3. #3
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116
    What does it mean when I get user-defined type not defined on

    DIM rstForm AS DAO.RECORDSET

  4. #4
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    From any module, click on tools, references make sure Microsoft DAO 3.6 Object Library is selected.
    Inspiration Through Fermentation

  5. #5
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116
    Okay, that fixed it, but this code doesn't move to the next record. It just stays on the current record. Any ideas?

    Private Sub cmdNext_Click()
    On Error GoTo Err_cmdNext_Click
    Dim rstForm As DAO.Recordset
    Set rstForm = Me.RecordsetClone
    rstForm.Bookmark = Me.Bookmark
    rstForm.MoveNext
    If rstForm.EOF Then
    Me.QNumber.Visible = False
    Me.Question.Visible = False
    Me.sbfrmAnswers.Visible = False
    Me.cmdNext.Visible = False
    Me.cmdTestResults.Visible = True
    Me.lblEOF.Visible = True
    Else
    Me.QNumber.Visible = True
    Me.Question.Visible = True
    Me.sbfrmAnswers.Visible = True
    Me.cmdNext.Visible = True
    Me.cmdTestResults.Visible = False
    Me.lblEOF.Visible = False
    End If

    Exit_cmdNext_Click:
    Exit Sub

    Err_cmdNext_Click:
    MsgBox Err.Description
    Resume Exit_cmdNext_Click

    End Sub

  6. #6
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    It looks like you are using a navigation button to move thru your records. Since your not doing this through the OnCurrent event, you need to add
    DoCmd.GoToRecord , , acNext
    in then "Else" section of your code.
    Inspiration Through Fermentation

  7. #7
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116
    Okay, that worked, but I get an error message when it reaches the last record that says you can't hide a control that has the focus. I think this is because of the sbfrm. What can I do?

  8. #8
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116
    Never mind!! I rearranged the order of the visible statements and added a set focus to move focus off the sbfrm. Thanks for all your help!!!

Posting Permissions

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