Tag: Data

The MIE Podcasts – Mike Alexander

In the second MIE podcast I chatted to Mike Alexander of Data Pig Technologies. In a fascinating conversation we talked Xcelsius, Microsoft  Access and its place in the scheme of things, and the prickly issues of Web Office and Open Source Office apps. Not to be missed!

Microsoft Master Mike Alexander!

Microsoft Master, Mike Alexander!

Please leave some comments with any feedback about this podcast, and also any ideas for future podcasts.

Thanks and enjoy

Ross

Parameters in ADO, getting good with Access – NOT!

Here’s the deal. Access database on a network share. Very, very, very complex set of queries (queries on queries on queries etc, etc). Ross, can you automate my reporting spread sheet?

So while the spreadsheet work is straight forward, the hard part here is getting the data into the spread sheet. I started off just writing some standard SQL and using ADO to pull a data set back. I soon realised, that the query had to be much more complex. In fact it was such a horrible set of logic, that I didn’t want to touch it with a barge pole!

What I thought I would try next is calling the query that the database used to produce a report, but return the dataset to my rs, and stick that in to Excel. That required the use of parameters that where getting fed into the underlying queries from a form in the database at run time. This was something I had not done with ADO before. A colleague showed me the way, basically:
[vba]

Private Sub GetData(dbName As String, sYear As String)

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Set cn = New ADODB.Connection

cn.Open “Provider=Microsoft.Jet.OLEDB.4.0; Data Source=” &  dbName & “;”

Set rs = New ADODB.Recordset

Dim qdf As New ADODB.Command
qdf.ActiveConnection = cn
qdf.CommandText = “SELECT * FROM [Some_Query];”

qdf.Parameters.Append qdf.CreateParameter(“Forms!Billing!Combo8″, adVarChar, adParamInput, 1, “”)
qdf.Parameters(0) = (“*”)
qdf.Parameters.Append qdf.CreateParameter(“Forms!Billing!Combo12″, adVarChar, adParamInput, 1, “”)
qdf.Parameters(1) = (“*”)
qdf.Parameters.Append qdf.CreateParameter(“Forms!Billing!Combo18″, adVarChar, adParamInput, 1, “”)
qdf.Parameters(2) = (“*”)
qdf.Parameters.Append qdf.CreateParameter(“Forms!Billing!Combo14″, adVarChar, adParamInput, 1, “”)
qdf.Parameters(3) = (“*”)
qdf.Parameters.Append qdf.CreateParameter(“Forms!Billing!Combo16″, adVarChar, adParamInput, 4, “”)
qdf.Parameters(4) = (sYear)
qdf.Parameters.Append qdf.CreateParameter(“Forms!Billing!Combo6″, adVarChar, adParamInput, 1, “”)
qdf.Parameters(5) = (“*”)

Set rs = qdf.Execute

rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing

End sub
[/vba]

This code worked!!!!  Success? Joy? The gratitude of an over worked account? Not quite.

The next snag was an Access classic “Undefined function”. The function that caused the error was MonthName, which produces a string indicating the specified month. This is not supported via DAO, so now what!?!?!

Here’s an inelegant solution. Copy the database, it’s a front end back end job, so just the UI/ reporting part; keep the linked tables and get ride of the stuff you don’t need. Add some code to call the required query in access and pass the parameters, you can do this with code like this:

[vba]
Sub GetData(ByVal Year As String, ByVal FullFilePath As String)

Dim qdf As QueryDef
Dim rst As Recordset

Set qdf = CurrentDb.QueryDefs(“final charges by project period and person”)

qdf.Parameters(0) = “*”
qdf.Parameters(1) = “*”
qdf.Parameters(2) = “*”
qdf.Parameters(3) = “*”
qdf.Parameters(4) = sYear
qdf.Parameters(5) = “*”

Set rst = qdf.OpenRecordset
‘Make Text File

Dim F As Integer
Dim I As Integer
F = FreeFile
Open sFullFilePath For Output As #F
‘Print Columns’ Headers
For I = 1 To rst.Fields.Count
Print #F, rst.Fields(I – 1).Name & “,”;
Next I
Print #F,
‘Print Data
Do While Not rst.EOF
For I = 1 To rst.Fields.Count
Print #F, rst.Fields(I – 1).Value & “,”;
Next I
Print #F,
rst.MoveNext
Loop
Close (F)

rst.Close
qdf.Close
Set rst = Nothing
Set qdf = Nothing
End Sub
[/vba]

You’ll notice that this also prints out a text file (nice!), So in Excel automate this copy of the mbd,  (which you stick on the same local PC as the excel spreadsheet, right!!!) then collect the text file in to Excel and there you have it! Perfection, no way, works, yes. Why the local copy? Well I didn’t what to “effect” the org db, and I didn’t what to automate over a slow network, I’m note sure if it’s a valid, but the thought of performing automation on a file saved on a network drive, doesn’t fill me with warm fuzzy feeling!

This may well be a contender for a WTF, but I’m WTF’d if I can think of a better way to solve the particular problem. Any ideas, ever done anything similar.

Excel 2007 Tables – the basics

Today I took my first look at Excel 2007 tables. I’ve hardly use Excel 2007, for obvious reasons, so I’ve not really played with many of the “new” features.

I did a bit of research and basically there are already a few good spots out there for table related stuff:

An incredibly cheesy Microsoft video, it does show all the main features (doesn’t that table look professional!)

Jan Karel Pieterses’ introduction and VBA methods

And Ron de Druin VBA page here

This chart shows my feeling towards tables in Excel 2007 over the last 3 hours:

Excel 2007 Data Tables

In summary, I think tables have been done really well, there are easy to use and makes sense. I think that the new reference system (table name[column])  is good, but just like named ranges, can cause as many issues as it might solved, especially when used by relatively low skilled Excel users.  Most of the stuff that I can see in tables was already there, and has “just” been made much easier to get at, I like the auto-update-y nature of tables, but that always worries me a bit too.
Just for completeness I have done a quick video to add to the tables database!

Reporting Services with SQL Express and VS 2005.

Nice little article on using Reporting Services with SQL Server 2005 Express and Visual Studio 2005.
http://www.vsj.co.uk/articles/display.asp?id=608

VSJ, btw is worthwhile joining, they send you a propper printed out mag each month for free and it quite good too!

Reporting and Analysis

There are many different definitions of reporting and analysis.

I was interested to read what Zack at Juice Analytics had to say on the matter. To paraphrase, reporting is for things we know well and are predictable where as analysis if for things that are unknown and erratic. Now I’ve only looked at the slides (check them out there good!) so I may have missed the context, but that’s not really the point.

The point is that to me reporting is the process of getting the data on to the screen or paper, digging it out cutting it up that sort of thing. Analysis to my mind, is the process of trying to find out what the hell is going on and why! Business intelligence (a now out of date phrase I believe!) it therefore the process of bringing reporting and analysis together and giving it to the information user who uses it to make decisions.

That’s how I see it any road. (aka: Just my 2 cents!)

I think Zacks’ and my views are both valid, although slightly different. I wonder what other views of reporting and analysis there are?