MSFlexGrid & Dates & other
HY, friends.
I have a database (data1.recordset) containing following relevant fields
shown within an MSFlexGrid:
.(âlastnameâ) âselfexplanatory
.(âarrivaldateâ) as above
.(âdepartureâ) as above
.(âroomnoâ) as number of room for an hotel
The row header shows dates for 365 days
The column header shows numbers of existing rooms
Now I need to fill the MSFlexGrid with lastnames into the proper dates/roomno cells
indicating the days a guest stay at the hotel.
To do so I have this code which have heavy problem and has to be remanipulated:
First of all loop in all records of data1
âBEGIN
dim column as integer
dim row as integer
dim ind as integer
Data1.Recordset.MoveFirst
Do While Not Data1.Recordset.EOF
' looking for proper column (the date)
column = DateDiff(âdâ,Data1.Recordset.Fields(âarrival dateâ), MSFlexGrid1.TextMatrix(0, 0))
' looking for proper row (the room number)
row = 0 ' row containing the cell to be filled
For ind = 1 To MSFlexGrid1.Rows
If MSFlexGrid1.TextMatrix(ind, 0) = Data1.Recordset.Fields(âroomnoâ) Then
row = ind
Exit For
End If
Next ind
' Filling the row of room with cells corresponding to days in which
âclient occupied it
For ind = 1 To DateDiff("d", Data1.Recordset.Fields(âarrivaldateâ), Data1.Recordset.Fields(âdepartureâ))
MSFlexGrid1.TextMatrix(row, column + ind - 1) = Data1.Recordset.Fields(âlastnameâ)
Next ind
Data1.Recordset.MoveNext
Loop
âEND
I receive back error messages like: âinterval not included â¦â ⦠some âlastnamesâ
Appearing in the row headers, and so on.
This code has heavy problem.
Does anyone is so kind to suggest correction or a new one?
This will solve a vital problem and canât by myself.
Thanks in advance.
|