MSFlexGrid & correct pupulating
Hy Friends.
I have following code for an MSFlexGrid determining status of hotel rooms (empty, occupied):
Begin
-------
Private Sub form_load()
'this is for calendar (row 0)
MSFlexGrid1.Cols = 366
mydate = Date - 10 ' (-10 allows to see 10 days bifore Date)
For i = 1 To 365
MSFlexGrid1.TextMatrix(0, i) = mydate
mydate = DateAdd("d", 1, mydate)
Next
'this is for rooms number
MSFlexGrid1.Row = 0
MSFlexGrid1.col = 0
Dim mysql As String
Dim myrs As Recordset
MSFlexGrid1.TextMatrix(0, 0) = "Room"
Set mydb = DBEngine.OpenDatabase(App.Path & "/my.mdb")
mysql = "Select roomno from room"
Set myrs = mydb.OpenRecordset(mysql)
myrs.MoveFirst
Do While Not myrs.EOF
For i = 0 To myrs.Fields.Count - 1
MSFlexGrid1.AddItem myrs.Fields("roomno")
myrs.MoveNext
Next i
Loop
myrs.Close
mydb.Close
End Sub
End
----
This work perfectly but MSFlexGrid is empty and has to be populated. Now, I have a database (a simple data1.recordset) with following relevant fields:
.recordset.fields(âroomnoâ) for number of rooms
.recordset.fields(âarrivaldateâ) for date of arrival
.recordset.fields(âdepartureâ) for date of checkout
.recordset.fields(âlastnameâ) for the name of the guest
What I have to get is to see the lastname of guest in the proper cell for the period of staying, which means that the rows correct will be the one corrisponding to the number of room (indicated in Col 0), first cell occupied by lastname on arrivaldate, all the other cell of rows occupied by lastname until the last one corrisponding of the last night (departure â1).
Good should be to have .backcellcolor with a different color.
How to proceed ?
|