Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 27th, 2003, 10:42 AM
ric ric is offline
Registered User
 
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 ?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Pupulating datagrid based on selected items swati_joshi ASP.NET 1.0 and 1.1 Basics 1 March 27th, 2006 04:22 PM
MSFlexGrid loveperson Beginning VB 6 1 January 18th, 2005 11:45 AM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM
MSFlexGrid & Dates & other ric Pro VB 6 1 December 10th, 2003 05:47 AM
MSFlexGrid meireliezer Visual C++ 0 November 19th, 2003 07:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.