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!
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!