SortAscenting isn't available now

  • Thread starter Thread starter deb
  • Start date Start date
D

deb

I have two buttons on top of each other and when it is clicked it sorts asc
or desc. this works on some fields but not the ones that the control sorce
is calculated.

I have the below code attached to buttons in a form...
Private Sub PMBudgetedMoAsc_Click()
PMBudgetedMo.SetFocus
DoCmd.RunCommand acCmdSortAscending
Me!PMBudgetedMoDesc.SetFocus
End Sub

Private Sub PMBudgetedMoDesc_Click()
PMBudgetedMo.SetFocus
DoCmd.RunCommand acCmdSortAscending
Me!PMBudgetedMoAsc.SetFocus
End Sub

When the button is clicked it gives me a runtime error 2046
The command or action SortAscenting isn't available now

I use this on other fields in a form . the only difference is the field is
calculated by using =[ForeCastK]/[Months] in the control source.

any ideas on how i can make this work
 
deb said:
I have two buttons on top of each other and when it is clicked it sorts asc
or desc. this works on some fields but not the ones that the control
sorce
is calculated.

I have the below code attached to buttons in a form...
Private Sub PMBudgetedMoAsc_Click()
PMBudgetedMo.SetFocus
DoCmd.RunCommand acCmdSortAscending
Me!PMBudgetedMoDesc.SetFocus
End Sub

Private Sub PMBudgetedMoDesc_Click()
PMBudgetedMo.SetFocus
DoCmd.RunCommand acCmdSortAscending
Me!PMBudgetedMoAsc.SetFocus
End Sub

When the button is clicked it gives me a runtime error 2046
The command or action SortAscenting isn't available now

I use this on other fields in a form . the only difference is the field
is
calculated by using =[ForeCastK]/[Months] in the control source.

any ideas on how i can make this work


I haven't encountered this problem, but I suspect that you'll need to move
the calculation into the form's recordsource query itself. That is, add a
calculated field to the query:

PMBudgetedMo: [ForeCastK]/[Months]

and on the form, bind the text box directly to the calculated field.
 
Back
Top