Refresh Subform when clicking navigation button on main form

  • Thread starter nerb61 via AccessMonster.com
  • Start date
N

nerb61 via AccessMonster.com

I'm still having a problem with my subform not refreshing when I click Next
on my main form. My subform takes the user through a series of questions on
an issue - the main form takes the user to the next issue. If the user clicks
Next on the main form without returning to question number 1 on the subform
(using the previous button), the subform does not start with question number
1 on next issue, and does not allow user to use Previous button (You can't go
to specified record) to get there. I thought if I added a requery subform to
the Next button on the main form, but that didn't work.

The code is nothing fancy:

Subform code:

Sub SetNavButtons (SomeForm As Form)

On Error GoTo SetNavButtons_Error

With SomeForm
If .CurrentRecord = 1 Then
.cmdNextRec.SetFocuc
.cmdPreviousRec.Enabled = False
ElseIf .CurrentRecord = .RecordSet.RecordCount Then
.cmdPreviousRec.Enabled = True
.cmdPreviousRec.SetFocus
.cmdNextRec.Enabled =False
Else
.cmdPreviousRec.Enabled = True
.cmdNextRec.Enabled = True
End If
End With

SetNavButtons_Exit:

On Error Resume Next
Exit Sub

SetNavButtons_Error:

MsgBox "Error " & Err.Number & " (" Err.Description &_
") in procedure SetNavButtons of Module modFormOperations"
GoTo SetNavButtons_Exit

End Sub
___________________________________________________________

Private Sub cmdNextRec_Click()

On Error GoTo cmdNextRec_Click_Error

If me.newrecord then
me.dirty = false
else
docmd.gotorecord , , acnext
call setnavbuttons (me)

end if

cmdnextrec_click_exit:

on error resume next
exit sub

cmdnextrec_click_error

msg "error "
goto cmdnextrec_click_exit

end sub
________________________________________

Main Form Code:

Public Sub cmd NextKeyDecision_Click()

On Error GoTo cmdNextKeyDecision_Click_Error

If Me.NewRecord Then
Me.Dirty = False
Else
DoCmd.GoToRecord , , acNext
End If

cmdNextKeyDecision_Click_Error:

MsgBox "Error "

GoTo cmdNextKeyDecision_Click_Exit

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top