Problem with Navigation Buttons

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

nerb61 via AccessMonster.com

Follow-up to earlier question from a couple of weeks ago. I thought I had it
working, but I ran into a problem. I have Navigation buttons on a subform
that navigate through a series of questions. Code below. The problem is when
the user goes to the navigation buttons on the main form moving to the next
issues which takes them through another set of questions - the subform
navigation buttons get crazy. The questions don't start with number one and
you can't always go Next and Previous without a Can't go to specified record
error. Any ideas???


Sub SetNavButtons(SomeForm As Form)

On Error GoTo SetNavButtons_Error

With SomeForm
If .CurrentRecord = 1 Then
.cmdNextKeyDecision.SetFocus
.cmdPrevKeyDecision.Enabled = False
ElseIf .CurrentRecord = .Recordset.RecordCount Then
.cmdPrevKeyDecision.Enabled = True
.cmdPrevKeyDecision.SetFocus
.cmdNextKeyDecision.Enabled = False

Else
.cmdPrevKeyDecision.Enabled = True
.cmdNextKeyDecision.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
 
K

Klatuu

How are you call SetNavButtons from the sub form? It could be a form
referencing problem.
Call SetNavButtons(Forms!MainForm!SubForm)
 
N

nerb61 via AccessMonster.com

I have the Sub SetNavButtons(SomeForm As Form) on the Subform and then code
on the Next and Previous buttons (also on the subform). I have no reference
on the main form. When I return to the main form, I want it to start back on
number 1 in the subform.

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:

MsgBox "Error "
GoTo cmdNextRec_Click_Exit

End Sub





How are you call SetNavButtons from the sub form? It could be a form
referencing problem.
Call SetNavButtons(Forms!MainForm!SubForm)
Follow-up to earlier question from a couple of weeks ago. I thought I had it
working, but I ran into a problem. I have Navigation buttons on a subform
[quoted text clipped - 37 lines]
 
K

Klatuu

I don't think you understood my question or suggestion. It is not a problem
with the Sub. I think it is a problem with how you reference the form when
you call the sub. If you just pass it the subform name, the Sub may not be
able to find it correctly. When you call the Sub, include the full reference
as in my previous post.

nerb61 via AccessMonster.com said:
I have the Sub SetNavButtons(SomeForm As Form) on the Subform and then code
on the Next and Previous buttons (also on the subform). I have no reference
on the main form. When I return to the main form, I want it to start back on
number 1 in the subform.

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:

MsgBox "Error "
GoTo cmdNextRec_Click_Exit

End Sub





How are you call SetNavButtons from the sub form? It could be a form
referencing problem.
Call SetNavButtons(Forms!MainForm!SubForm)
Follow-up to earlier question from a couple of weeks ago. I thought I had it
working, but I ran into a problem. I have Navigation buttons on a subform
[quoted text clipped - 37 lines]
 

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