Tuesday, November 25, 2008

Access: Using a combo or list box to navigate a form's record set

You'd expect access to have some of this functionality out of the box (.net does).
Not to worry, here's the code that seems to work:
Private Sub StdNoList_AfterUpdate()
Dim rs As DAO.Recordset
If Not IsNull(Me.StdNoList) Then
If Me.Dirty Then Me.Dirty = False
Set rs = Me.RecordsetClone
rs.FindFirst "pricing_id = " & Me.StdNoList & ""
If rs.NoMatch Then
MsgBox "Not Found"
Else
Me.Bookmark = rs.Bookmark
End If
End If
Set rs = Nothing
End Sub

Friday, November 21, 2008

Crystal: passing parameters to child reports

Say you only want to ask the user for a report parameter once and want to use the parameter in multiple reports. The best way I've found to do this is:
  1. Create the parameter in the parent report
  2. Link the parameter to any ole field in the child report
  3. Remove the parameter in any selection criteria in the child report (unless you do really want it used)
  4. Consume the parameter in calculated fields

Thursday, November 20, 2008

Crystal: summarising formula fields

For some crazy reason, it seems that Crystal won't easily let you summarise (sum, average, etc) calculated values. After trawling the net for a while I managed to come up with the following 'hack' to achieve this.
  1. Create a calculated field that clears an array variable & returns "";
  2. Insert this field into a group or report header;
  3. Create a calculated field that re-dimensions the array variable with an extra element, adds the calculated value to the array & returns "";
  4. Insert this field into a details line;
  5. Create a calculated field that summarises the array variable & return this out put;
  6. Insert this field into a group or report header.

Workforce analytics - developmental stages

Just came across this article by infohrm discussing the development of workforce analytics / metrics in organisations.
I particularly liked the descriptions given for each of the 'developmental phases':
Phase 1: Service Provider: Organisations at Phase 1 are primarily reactive in their approach, with a workforce reporting team that responds to ad-hoc requests for transactional data, prepares one dimensional performance reports and maintains HR databases.
Phase 2: Business Enabler: These organisations are seeking to improve data efficiency, the team provides reporting self service for end users, places a focus on data accuracy and consistency, and automates common information requests.
Phase 3: Business Partner: At stage three a shift occurs whereby the focus is on engaging with the business rather than just supporting it. The team moves beyond reporting to provide support for integrating data into business planning processes, and takes steps toward identifying workforce trends.
Phase 4: Business Driver: Building on the experience gained in Phase 3, the team shifts its focus toward issue analytics and workforce planning to quantify the impact of human capital on the business and forecast the future workforce. The first two stages can be met by a successful data implementation and roll out of reports and dashboards to the users. A shift occurs in the second two phases whereby there is a cultural change within Human Resources.

Tuesday, November 18, 2008

Crystal: sharing variables between sub and main reports

Crystal reports is none to friendly when it comes to incorporating information from sub queries. It appears that the best way to do this is to create a sub report with a shared variable that you can then make use of in the parent report. While you can include this variable in calculations, it appears that you can’t summarise (sum / average / etc) the variable.
Here is the step-by-step guide I came across at https://boc.sdn.sap.com/node/251
Synopsis
A report contains a subreport. Data from the subreport is required for calculations in the main report.
How can you share subreport data with the main report in version 7 (or higher) of the Crystal Reports Designer?
Solution
Shared variables, introduced in Crystal Reports version 7, make it easier to pass values from a subreport to the main report. Using shared variables requires two formulas: one to store the value in a shared variable, the other to retrieve the value from the shared variable.
The most important thing to remember when using shared variables is that Crystal Reports must first evaluate the formula where the value is stored before evaluating the formula that retrieves the shared variable.
For example if you want to pass a grand total from the subreport to do a calculation in the main report, follow these steps:
1. In the subreport, create a formula similar to the one below:
//@SubFormula
//Stores the grand total of the
//{Orders.Order Amount} field
//in a currency variable called 'myTotal'
WhilePrintingRecords;
Shared CurrencyVar myTotal := Sum ({Orders.Order Amount})
2. Place this formula in your subreport.
3. In the main report, create a formula that declares the same variable name:
//@MainFormula
//Returns the value that was stored
//in the shared currency variable called
//myTotal in the subreport
WhilePrintingRecords;
Shared CurrencyVar myTotal;
myTotal
4. Place @MainFormula in a main report section that is beneath the section containing the subreport.
NOTE:======
For the shared variable to return the correct value in the main report, you must place @MainFormula in a main report section that is beneath the section containing the subreport. This ensures Crystal Reports evaluates the @SubFormula before @MainFormula.
One way to do this is to insert a section below the section containing the subreport, and place @MainFormula in this new sub-section:
· On the 'Format' menu, click 'Section'.
· On the 'Sections' list, click the section containing the subreport.
· Click 'Insert' (at top of dialog box). This inserts an additional subsection.
· Click 'OK' to return to the report, and insert @MainFormula into this new sub-section.
The next time you preview the report, @MainFormula displays the value from the subreport. In this particular example, that value was the grand total of the {Orders.Order Amount} field.
============
5. Once you have verified that @MainFormula is returning the correct value from the subreport, you can include this formula in other main report formulas, such as:
//@NewFormula
//includes data from subreport
{@MainFormula}+ Sum ({Customer.Last Year's Sales})
· Place this formula in the same section as @MainFormula, or in a section further down on the report.
You have now successfully shared data from a subreport with the main report.
NOTE: =====
This is not possible with On Demand Subreports in Crystal Reports.