Monday, September 8, 2008

Workaround: Dangling Datasession Left After Running Report

In December, 2007, I posted about a bug in VFP 9 that causes a dangling datasession after running a report from form with a private datasession and using report listeners chained together as successors. Microsoft still hasn't fixed the problem, but I now have a workaround for the bug.

First of all ... I have to give credit where credit is due. I didn't come up with the solution. It was given to me by Rick Hawkins ... so thanks Rick!! But now that I have the solution, I want to share it with everyone who follows my blog (all three of you.)

The solution is actually quite simple ... just before you instantiate any report listener object, switch to datasession 1, instantiate the object, then switch back to the previous datasession.

LOCAL lnDataSession, loListener, loListener2

lnDataSession = SET('DataSession')
SET DATASESSION TO 1
loListener = CREATEOBJECT('ReportListener')
loListener.ListenerType = 1
loListener2 = CREATEOBJECT('ReportListener')
loListener.Successor = m.loListener2
SET DATASESSION TO (m.lnDatSession)

REPORT FORM Whatever OBJECT m.loListener


I'd rather Microsoft fix the bug, but I guess a workaround is the next best thing!

Monday, May 5, 2008

Problems with Code Sector - Direct Folders - Round 2

Wow ... what can I say other than, I'm shocked at the appalling behavior of this company.

In my previous blog post, I explained that this company has been less than responsive in my request for help because the product did not perform properly on Vista. I eventually asked for a refund and they were also non-responsive to that too. After posting that blog I sent a link to the company so they could see the bad publicity their behavior was generating. I received a comment on the blog stating:

"This problem was resolved on March 27, I'm sorry I forgot to let you know. You may download Direct Folders 3.31 or make a refund request at Plimus website".

Hmmm .. it's now May 5 and they "forgot" to inform me of the newer version, despite my repeated attempts to contact them and ask them when the new version was available. That didn't sit right with me so I decided I didn't want software from this company on my machine and I would just ask for a refund (yet again). Here's the reply I just got from them:

Dear Cathy,

Refunded. Next time test software before purchasing.

Best regards, Jeff


Whoa! Someone woke up on the wrong side of the bed!!! I'm shocked at what a snotty reply they sent me. I guess this just confirms that I don't want software from this company on my machine!

Saturday, May 3, 2008

Problems with Code Sector - Direct Folders

Back in February, I purchased a product called Direct Folders from Code Sector based on a recommendation of a colleague. This utility is supposed to provide an easier way to manage your folders. Unfortunately, that's not what happened for me.

I'm running Vista so I made sure the product was Vista compatible before purchasing. Their website said it was. So far, so good. I bought the product and installed it. So far, so good. Then I started using it .. not so good. Apparently, it only works correctly on Vista if you're running in Admin mode .. which I'm not! The "configuration" option is not accessible without Admin rights, yet that is the option that you're supposed to use to set the tool up to work the way you want. Kinda hard to set it up if you can't run the "Config" option!

I contacted product support and they told me they were working on a version that's more compatible with Vista. OK .. I can wait a little while .. but how long is a little while. I repeatedly asked them WHEN this newer version will be available and they never replied to any of my requests. After a month I got disgusted and uninstalled this product from my machine. I then asked them for a refund, explaining the problem. Again, I have gotten no responses from them despite repeated attempts to ask for a refund.

So apparently this company only responds when you're buying the product. Anything negative and they pretend they didn't hear you! BUYER BEWARE!!!

Tuesday, April 15, 2008

How Do I ... Total fields for one detail band only

When multiple detail bands were introduced to Visual FoxPro it was a great addition that was long overdue. However, there's one aspect of that feature that wasn't clearly thought through and that's Calculations and Report Variables.

Let's say you create a report with multiple detail bands. Then you add a data group to the report and in the data group footer you add some fields that are defined to calculate using the SUM option. The problem that can arise is the calculation is applied to every record in both detail bands and maybe you only want to sum the records in the first detail band. Hmmm ... now what?

There's a workaround, but it takes some extra work on your part. Start by defining a Report Variable called rnDetail; Set the Value to Store to 0; Set the Initial Value to 0; Set the Reset option to End of Report; and set the Calculation option to Sum. This creates a Report Variable that the Report Engine doesn't ever change but now you have something you can manipulate.

The next step is to make sure each of the detail bands are marked to include the associated header and footer bands. In the OnEntry Expression of the Detail Header 1 band, enter the expression: _VFP.SetVar('rnDetail', 1). In the OnEntry Expression of the Detail Header 2 band, enter the expression: _VFP.SetVar('rnDetail', 2). These two expressions reset the Report Variable to 1 or 2 at the beginning of the respective detail band so now you have a way to know which detail band you are on.

The next step is to create Report Variables for each of the fields you want to sum. For example, if you want to sum the Qty and Price in the first Detail Band, create a Report Variable called rnQty and set the Value to Store to IIF(rnDetail = 1, Qty, 0). Create another Report Variable called rnPrice and set the Value to Store to IIF(rnDetail = 1, Price, 0). Leave the Calculation option of both variables at the default of None.

The final step is to add the field objects to the data group footer band. Instead of using the name of the field such as Qty or Price, use your new Report Variables of rnQty and rnPrice for the expression. Set the Calculation options to reset at the data group. Now you have some calculations in the data group footer that only contain values from the first data detail band.

This concept can be used in various situations when you need to create calculations or Report Variables that only get processed on one of many detail bands. Once you have the rnDetail Report Variable in place, you can reference it as needed. Just be sure this Report Variable is at the top of the list of Report Variables before any other Report Variables that need to access it. The Report Engine processes the Report Variables in the order they appear in the list.

Monday, March 17, 2008

Happy St. Patrick's Day

I just had to take a moment today and blog about what a special day St. Patrick's Day means to me. No, I'm not Irish. No, I don't drink green beer. No, I don't really party much at all. So what's so special about this day?

Today marks the 26th anniversary of my life as a computer programmer!

I've been so blessed to have a career I enjoy and didn't want the day go by without saying so! It's actually quite ironic how I ended up in this career. During high school I was a shy, quiet, and very introverted girl (I know .. most of you can't believe that .. but it's true .. I swear!) I was looking for a career where I didn't have to socialize with people too much. We had an assembly at school where the administration talked about the "Career Center". This was a facility where Juniors and Seniors from high schools around the area could spend half their school day learning a career. There were programs for Auto Mechanics, Small Engine Repair, Cosmetology, and lots of other careers.

My mom really urged me to consider going to the Career Center. I resisted, but she's pretty persuasive. I considered the Accounting program because I really enjoyed my recent accounting class. I also considered the Engineering class because I really enjoyed my recent drafting class. My mom looked the brochure over and had this to say…

“I think you should consider this Computer program. I think computers are really going to take off in the future.”

Like I said, my mom is really persuasive so even though I had never touched a computer and didn’t know anything about them, I followed her recommendations. What can I say but, “Thanks Mom!” She was so right about the future of computers. She was also so right about the career choice for me.

I have loved being a programmer from the first day I started. It’s been a wonderful ride that has taken me many places. I have enjoyed the fact that to program an application for a business, I have to learn all about that business. I’ve had the opportunity to learn about so many different industries that I probably wouldn’t have ever known about. And the opportunity to work at Microsoft as a contractor was a dream come true!

I have also enjoyed the ironic affect this career has had on my life. I’m no longer the quiet, shy, introverted little girl. I’ve come out of my shell and now speak at user groups and conferences as often as I can. I write articles, post on newsgroups, and participate in the FoxPro community as much as possible. So to the entire FoxPro community .. I want to say thanks for the wonderful place you have helped my career go.

And I also owe a big “Thanks” to my Mom. She’s one special lady!

Wednesday, March 12, 2008

Cool Tool: Beyond Compare + Addon by Frank Perez

Beyond Compare is a great little utility that can be used to compare files. It's from Scooter Software and is only $30. What makes this utility even cooler is an addon written by Frank Perez (which is $FREE.) He wrote a utility that lets us compare FoxPro files ... like classes, forms, reports, and such. This is awesome ... I can't tell you how many times I have wanted to compare two different reports to see what is different!

Way to go Frank!!!

Read all about this on Frank's blog at http://www.pfsolutions-mi.com/blog/2008/03/08/BeyondCompare.aspx. I have added links in my Cool Tools section to Beyond Compare and to Frank's site for downloading the addon.

Enjoy!

Sunday, March 2, 2008

Call to Action - Install VFP 9 SP2

Rick Schummer just blogged a compelling call to action for everyone to install VFP 9 SP2 and test it. He took the time to write a whitepaper that explains how to install SP2 in a different directory than your VFP 9 RTM (Release to Manufacturing) or VFP 9 SP1 versions. This way you can leave your production version (RTM or SP1) as is, yet still have SP2 on the same machine so you can test your applications.

I can tell you that I had already previously followed his advice and have SP1 and SP2 running on my machine without any problems. I encourage everyone else to do the same. Rick did a great job in explaining why you should do this so I'm just going to point you to his blog which also has the link to his whitepaper.

http://rickschummer.com/blog/2008/03/vfp-9-rtmsp1sp2-one-machine.html

Please take the time to install and test SP2. If we all do this, the entire FoxPro Community, including yourself, will benefit!