- Joined
- Jan 11, 2008
- Messages
- 3
- Reaction score
- 0
Good morning!
The question is already in the thread title.
The code is bound to the On-Click event of a form, Access 2003 version. Now comes the confusing part:
The SQL string extracts fields CostCentre, CostCategory, SumOfCosts and Month from the table/another query. I'm struggling to populate the array with Month records only. It should look somewhat like this:
31.10.2007
31.10.2007
31.10.2007
30.11.2007
31.12.2007
Then the code should loop through the array records and create a new textbox on the form once the month changes. For example, 31.10.2007 is unequal to 30.11.2007 --> create a new textbox.
If you don't understand why the heck anyone needs to do something this confusing and inefficient, I'll be happy to explain the whole background of the task to you - maybe, there's a more elegant solution.
Arrays are just the only idea I've got.
This what I've got so far:
Any suggestions would be very much appreciated!!!!!!!!!!! Getting really desperate here.
Best,
DummiestDummy
The question is already in the thread title.
The SQL string extracts fields CostCentre, CostCategory, SumOfCosts and Month from the table/another query. I'm struggling to populate the array with Month records only. It should look somewhat like this:
31.10.2007
31.10.2007
31.10.2007
30.11.2007
31.12.2007
Then the code should loop through the array records and create a new textbox on the form once the month changes. For example, 31.10.2007 is unequal to 30.11.2007 --> create a new textbox.
If you don't understand why the heck anyone needs to do something this confusing and inefficient, I'll be happy to explain the whole background of the task to you - maybe, there's a more elegant solution.
This what I've got so far:
Code:
Set db = CurrentDb()
'SQL String to display results:
strSQL = "SELECT DISTINCT [Kostenart],[KoArt_Beschreibung],Sum([Kosten]) AS [Wert], [Bis]" & _ "FROM qryBasicSearch WHERE [KArtGr_Beschreibung] " & _ "IN(" & Criteria & ") AND [Kostenstelle] IN(" & Criteria1 & ")" & _ "AND [Bis]IN(#" & Periode & "#) " & _ "GROUP BY [Kostenart], [KoArt_Beschreibung], [Bis] " & _ "ORDER BY [Bis];"
Set rst = db.OpenRecordset(strSQL)
'count the records
With rst
i = .Fields.Count
j = .RecordCount
End With
'populate array
MyArray = rst.GetRows()
Dim x, y As Integer
'trying to display what's stored in the array
For x = 0 To UBound(MyArray) + 1
For y = 0 To j
MsgBox MyArray(y, x)
Next y
Next x
'clean up
rst.Close
Set rst = Nothing
Any suggestions would be very much appreciated!!!!!!!!!!! Getting really desperate here.
Best,
DummiestDummy