Hi everyone, I'm really an access newbie, and I need some help!
I've got one table, let's call it "data", that has a set of data with a Measure Name, and the corresponding monthly data in columns. For example:
Measure Name Jan 2014 Feb 2014 Mar 2014
Calls Answered 10 15 25
I have a function that takes the data from the above format, and puts it in the following format:
Measure Name Period Score
Calls Answered Jan 2014 10
Calls Answered Feb 2014 15
Calls Answered Mar 2014 25
Here's the function I'm using (I've left out a lot of the fields I'm really using just to make the example easier.
Function TransposeSLA()
Dim rsMySet As DAO.Recordset
Dim strSQL As String
Dim i As Integer
'Open the original matrix-style dataset
Set rsMySet = CurrentDb.OpenRecordset("SLA_Data")
'Start the count at the position number of the first column-oriented field
'Remember that Recordsets start at 0
For i = 16 To rsMySet.Fields.Count - 1
'Use the recordset field.name property to build out the SQL string for the current field
strSQL = "INSERT INTO SLA_Transposed ([Account], [SBU Manager], [SLA Type], [SLAName], [Capability], [TargetDirection], [Target], [Period], [Score]) " & _
"SELECT [SLA_Data].[Account], [SLA_Data].[SBU Manager], [SLA_Data].[SLA Type], [SLA_Data].[SLAName], [SLA_Data].[Capability], [SLA_Data].[SLA Target Direction], [SLA_Data].[SLA Target], " & _
"'" & rsMySet.Fields(i).Name & "'" & " AS Month, " & _
"[" & rsMySet.Fields(i).Name & "] " & _
"FROM SLA_Data;"
'Execute the SQL string
CurrentDb.Execute strSQL
'Move to the next column-oriented field
Next i
End Function
The function above puts the data in a new table called "Transposed" in the format I need. The user accomplishes this by clicking a "button" on a form. The button also deletes the existing table / records from Transposed. I now need to change it so that only NEW data from the "data" table is transposed by the function INTO the table "Transposed". The reason for this is that my client decided they want to do some additional data entry in the transposed table. As it is right now, they can't, because the table is deleted each time they click the button on the form to add new data.
Any suggestions / help on how I can accomplish this is greatly appreciated!