I have a form with three buttons for a user selection. This determines the table sort order, a label caption and what controls are to be used on a separate form.
The first two selections work as expected but the third, "BoxNo", causes the program to go off track.
The selection form, "Choices" is opened "acDialog" from the main form's "onLoad" event which then calls getOrder() after "choices" closes.
If I put in a break point at the top of the sub it will step down to the third setorderby as expected.
If I comment out that line the code runs correctly but without the required table order.
There is no error detected in this code block.
"transfer" is a public variable that is set by the user selected option in "Choices".
I have retyped the code, shifted things around and drank copious amounts of coffee, all to no avail.
Moving the offending elseif statement to the top of the code block causes the same problem.
The code freezes at a docmd.close statement in another sub with runtime error 2585, sometimes requiring a complete shutdown and restart of Access.
At this point it would seem that the problem is in the "DoCmd.SetOrderBy "Boxno" line.
The first two selections work as expected but the third, "BoxNo", causes the program to go off track.
The selection form, "Choices" is opened "acDialog" from the main form's "onLoad" event which then calls getOrder() after "choices" closes.
If I put in a break point at the top of the sub it will step down to the third setorderby as expected.
If I comment out that line the code runs correctly but without the required table order.
There is no error detected in this code block.
"transfer" is a public variable that is set by the user selected option in "Choices".
I have retyped the code, shifted things around and drank copious amounts of coffee, all to no avail.
Moving the offending elseif statement to the top of the code block causes the same problem.
The code freezes at a docmd.close statement in another sub with runtime error 2585, sometimes requiring a complete shutdown and restart of Access.
At this point it would seem that the problem is in the "DoCmd.SetOrderBy "Boxno" line.
Code:
Private Sub getOrder()
On Error GoTo Err_bugger
DoCmd.SelectObject acForm, "NoGenus"
If transfer = "Genus" Then
DoCmd.SetOrderBy "Genus"
Me.cboGenus.SetFocus
Me.lblNGNE.Caption = "No Genus"
Me.cboGenus.Dropdown
ElseIf transfer = "Species" Then
DoCmd.SetOrderBy "Speciesepithet"
Me.lblNGNE.Caption = "No Epithet"
Me.txtEpithet.SetFocus
ElseIf transfer = "BoxNo" Then
DoCmd.SetOrderBy "Boxno"
Me.lblNGNE.Caption = "No Box Numbers"
Me.txtBoxNo.SetFocus
End If
transfer = ""
Exit Sub
Err_bugger:
MsgBox Err.Number & Err.Description
End Sub