How do you use dataset in your report?I would say you use TfrUserDataset, and you don't correctly initialize your variables in OnFirst event. You have to initialize your variables there, because OnFirst event is called two times when report is 'Two-pass report'.
I am using TBufDataset in this project.