MSFlexGrid merge problem..

epod69
02-18-2005, 02:51 PM
Ok, I will try to explain the problem as best I can. I dont really understand why it is doing this because the code seems just fine to me.

In my flexgrid, I am merging cells, and for some odd reason, it just sometimes decides not to do it.

Here is the code:

Do Until MyRecSet_cal.EOF

If Format(MyRecSet_cal!Time, "AM/PM") = "AM" Then

With MSFlexGrid1

If .Rows = (.Row + 1) Then

If Not .Row = 0 Then

.Rows = .Rows + 2
.Row = .Row + 1

End If

End If

time_for = Format(MyRecSet_cal!Time, "Hh:Nn AM/PM")
time_for_sort = Format(MyRecSet_cal!Time, "Hh.Nn")
db_type = "Appointment"

.MergeCells = flexMergeRestrictColumns
.Text = time_for & vbCr & "Appointment"

Debug.Print .Row & .Col & " " & .Text

.Row = .Row + 1
.Text = time_for & vbCr & "Appointment"
.MergeCol(0) = True

Debug.Print .Row & .Col & " " & .Text

.Col = 1
.Row = .Row - 1
.Text = time_for_sort
.Row = .Row + 1
.Text = time_for_sort
.MergeCol(1) = True

.Col = 2
.Row = .Row - 1
.Text = db_type
.Row = .Row + 1
.Text = db_type
.MergeCol(2) = True
.Col = 0

End With

End If

If Format(MyRecSet_cal!Time, "AM/PM") = "PM" Then

With MSFlexGrid2

If .Rows = (.Row + 1) Then

If Not .Row = 0 Then

.Rows = .Rows + 2
.Row = .Row + 1

End If

End If

time_for = Format(MyRecSet_cal!Time, "Hh:Nn AM/PM")
time_for_sort = Format(MyRecSet_cal!Time, "Hh.Nn")
db_type = "Appointment"

.MergeCells = flexMergeRestrictColumns
.Text = time_for & vbCr & "Appointment"
.Row = .Row + 1
.Text = time_for & vbCr & "Appointment"
.MergeCol(0) = True

.Col = 1
.Row = .Row - 1
.Text = time_for_sort
.Row = .Row + 1
.Text = time_for_sort
.MergeCol(1) = True

.Col = 2
.Row = .Row - 1
.Text = db_type
.Row = .Row + 1
.Text = db_type
.MergeCol(2) = True
.Col = 0

End With

End If

MyRecSet_cal.MoveNext

Loop

There is one event that triggers this code that just doesnt want to merge. So I placed the debug.print to find out the demensions or where the cells are being edited.

The debug.print showed this:
00 09:15 AM
Appointment
10 09:15 AM
Appointment
20 10:50 AM
Appointment
30 10:50 AM
Appointment

So..the cells are right where they are suppose to be and have matching text so you would they they would be merging..but they arent.

What is wierd is when the form loads up, it shows the cells completely different then the debug.print shows.

It shows the first cell, 09:15 AM Appointment and the second cell 10:50 AM Appointment and the same thing for cells 3 and 4. I dont see anywhere in the code where the cells would be switching around =(. And what makes it even more wierd, is that if you trigger the event again while the form is open. The cells get merged just how they are suppose to Oo!! So I am very confused right now and sorry if I explained it badly, I tried my best.

So if anyone has any suggestions to what may be causing the problem, that would be awsome. Thanks everyone!

Flyguy
02-19-2005, 02:25 AM
It's very hard to simulate this because we don't have your recordset with data.
Can you make a small routine which seems to have to same problem, but not relying on a recordset?

epod69
02-22-2005, 08:40 AM
Ok..I have been trying but cant figure out what is causing the problem.

So..I attached my project HERE (http://www.angelfire.com/pro2/visualbasic/Debug.zip) , well part of it which has the two forms which are causing the problem.

Edit: you have to right click, copy shortcut, and paste to address bar to get the zip file.

When you run the project, you will be brought to a calandar. From the calandar, you can double click on a bolded date (a date with events) and it will bring up all the events for the day. This part works just fine. Now, what I started to work on, is if there is an appointment event (the word appointment will be highlighted blue) and you click on the word appointment, it will only show appointments for the day. This all works fine exept for one day. If you click on appointments for the first day, then thats when the cells dont merge. But if you click on it again while the other form is still up, it will merge again.

Anyways, still trying to keep this short, and it would be so nice if someone could glance at my project and see what might be causing the problem, any other input on the project would be nice as well. Thanx everyone so much for helping!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum