Click to See Complete Forum and Search --> : MSFLEXGRID Query
nmretd
Jan 17th, 2000, 01:41 AM
I have populated my Grid is as folows:
01/01/00 02/01/00 03/01/00 04/01/00 05/01/00
A
B
Consider the following Access table:
Name Start Finish
A 01/01/00 05/01/00
B 02/01/00 04/01/00
I want to put an X in every cell to show the Start and Finish Range. i.e The Completed Grid will look as follows:
01/01/00 02/01/00 03/01/00 04/01/00 05/01/00
A x x x x x
B x x x
Can someone please show me how to code this ?
netSurfer
Jan 17th, 2000, 02:26 AM
if you use the example I gave you before for finding the field name, you could loop through the table looking at Field Names, if it was less then the data specified, write an X into the field. Does this help or would you like me to post the code again?
SCRATCH THAT ---- I'm an idiot. I didn't see that you want it with the grid. That's even easier, just loop through the first row, checking if the name is less than the date specified.
For example:
dim strSDate as string, strEDate as string, strName as string, intI as integer, intJ as integer, intRow as integer
'strName and the start and end date strings are set
intRow = grdTable.row 'mark the row using
for intI = 0 to grdTable.cols -1
grdTable.row = 0
grdtable.col = intI
if cdate(strEDate) <= cdate(grdTable.text) then
grdTable.row = intRow
grdTable.text = "X"
end if
next inti
Assuming the grdTable is the grid you're using, the start date you already have done to put the A or B in. If you're not sure how to do this, similar to the loop above but search for the strSDate instead.
[This message has been edited by netSurfer (edited 01-17-2000).]
nmretd
Jan 17th, 2000, 05:04 AM
Thanks netsurfer, I have tried to put it all together but I'm still having problems. Please can you help me. So far I have the following:
Dim db As Database
Dim oRs As Recordset
Dim strSDate As String
Dim strEDate As String
Dim strName As String
Dim intI As Integer
Dim intJ As Integer, intRow As Integer
Set db = OpenDatabase("c:\DB1.mdb")
Set oRs = db.OpenRecordset("SELECT Name from Table1")
While Not oRs.EOF
strName = oRs(0)
For i = 0 To oRs.Fields.Count - 1
?
Next i
oRs.MoveNext
Wend
Set oRs = Nothing
db.Close
Set db = Nothing
intRow = MSFlexGrid1.Row 'mark the row using
For intI = 0 To MSFlexGrid1.Cols - 1
MSFlexGrid1.Row = 0
MSFlexGrid1.Col = intI
If CDate(strEDate) <= CDate(MSFlexGrid1.Text) Then
MSFlexGrid1.Row = intRow
MSFlexGrid1.Text = "X"
End If
Next intI
Please can you show me the final steps to complete this. Thanks.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.