I think I have a syntax problem.
If I use the following code the system works fine. I can scroll through the records as expected.
If I use the following code I get a message " Can't go to that record" even before the form has loaded.
Ideally I would like to be able to change the sort order via a subform that loads the "sortorder" variable with the required fields.
These fields are selected via three comboboxes and combined with the following code
The sort order is then changed in the parent form's oncurrent event
If I use the following code the system works fine. I can scroll through the records as expected.
Code:
DoCmd.SetOrderBy "boxno" & "," & "family" & "," & "accessionnumber"
Me.OrderByOn = True
If I use the following code I get a message " Can't go to that record" even before the form has loaded.
Code:
sortOrder = "boxno" & "," & "family" & "," & "accessionnumber"
DoCmd.SetOrderBy sortOrder
Me.OrderByOn = True
Ideally I would like to be able to change the sort order via a subform that loads the "sortorder" variable with the required fields.
These fields are selected via three comboboxes and combined with the following code
Code:
Private Sub btnSort_Click()
If Me.cboSort1 <> "" Then
sortOrder = cboSort1
End If
If Me.cboSort2 <> "" Then
sortOrder = sortOrder & ", " & cboSort2
End If
If Me.cboSort3 <> "" Then
sortOrder = sortOrder & ", " & cboSort3
End If
DoCmd.Close acForm, Me.Name
End Sub
The sort order is then changed in the parent form's oncurrent event