vba - Sorting of a calculated field fails when using report within a form in Access -


i have report code sort on calculated column, when user clicks label report sorted, here's code:

private sub label44_click()  if me.orderby = "iif([sumofcurrentpricevol]<>0,([sumofofferedpricevolume]-[sumofcurrentpricevol])/[sumofcurrentpricevol],0) desc"     me.orderby = "iif([sumofcurrentpricevol]<>0,([sumofofferedpricevolume]-[sumofcurrentpricevol])/[sumofcurrentpricevol],0) asc" else     me.orderby = "iif([sumofcurrentpricevol]<>0,([sumofofferedpricevolume]-[sumofcurrentpricevol])/[sumofcurrentpricevol],0) desc" end if  me.orderbyon = true end sub 

when use report works fine. if put report inside of form following error message:

"run-time error '5': invalid procedure call or argument"

at

me.orderbyon = true 

i tried changing me report , same results. idea of may failing?

i able re-create issue. it's not complicated calculation may want add recordsource. re-created simple sort of single field. here's found:

(sorry don't seem able upload images here; unfortunate)

check report properties' [data] tab , see order on load. it's set yes. means don't need turn on, because it's on.

but @ same time, default value orderby null. report tell orderbyon = false if there's null value in orderby, despite fact order on load true!

so basically, need set default orderby in properties, set default oderby in report_activate() event, or update code a/the 1 time null value.

why given code works in report, not subreport mystery; maybe bug. able resolve issue doing 1 of 3 suggestions above.

oh, , don't forget remove me.orderbyon = true because what's causing issue...some sort of half baked read-only error triggered in subreport.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -