Hi there
I have data in a table that reads:
1
1
1
1
2
2
2
3
3
I would like to insert a blank row between each block of data ie:
1
1
1
1
2
2
2
3
3
I have a query (called qryDifferences)that counts the rows of each group, somehow i now need to use the recordset method to insert a blank row using this query as a reference to how often it inserts the row.
I have this probably laughable attempt at this stage:
Dim dbs As Database, qdf As QueryDef, strSQL As String
Dim rst As Recordset
Set dbs = CurrentDb
strSQL = "SELECT [tblExportInvoices].[Invoice ID], Count([Invoice ID]) AS Difference, " & _
" FROM [tblExportInvoices] GROUP BY [tblExportInvoices].[Invoice ID];"
Set rst = dbs.OpenRecordset("qryDifferences", dbOpenForwardOnly)
While (Not rst.EOF)
For i = 1 To rst!Difference
insSQL = "INSERT into tblExportInvoices ([Invoice ID]) VALUES ('')"
' MsgBox (insSQL)
dbs.Execute (insSQL)
Next
rst.MoveNext
Wend
Set rst = Nothing
Set dbs = Nothing
It currently adds a row for each group but not in between the records. Any help would be greatly appreciatd.
Thanks
Richard
I have data in a table that reads:
1
1
1
1
2
2
2
3
3
I would like to insert a blank row between each block of data ie:
1
1
1
1
2
2
2
3
3
I have a query (called qryDifferences)that counts the rows of each group, somehow i now need to use the recordset method to insert a blank row using this query as a reference to how often it inserts the row.
I have this probably laughable attempt at this stage:
Dim dbs As Database, qdf As QueryDef, strSQL As String
Dim rst As Recordset
Set dbs = CurrentDb
strSQL = "SELECT [tblExportInvoices].[Invoice ID], Count([Invoice ID]) AS Difference, " & _
" FROM [tblExportInvoices] GROUP BY [tblExportInvoices].[Invoice ID];"
Set rst = dbs.OpenRecordset("qryDifferences", dbOpenForwardOnly)
While (Not rst.EOF)
For i = 1 To rst!Difference
insSQL = "INSERT into tblExportInvoices ([Invoice ID]) VALUES ('')"
' MsgBox (insSQL)
dbs.Execute (insSQL)
Next
rst.MoveNext
Wend
Set rst = Nothing
Set dbs = Nothing
It currently adds a row for each group but not in between the records. Any help would be greatly appreciatd.
Thanks
Richard