SortAscenting isn't available now

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
 
D

Dirk Goldgar

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.
 

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