Can't seem create the last column of the Grid by itself in the vbAccelerator Grid for Outlook 2007 VBA script

We are working in Outlook 2007 VBA using a Grid from vbAccelerator.com

For some strange reason, we can't seem to get the last column (in the example below is "Comments") to display without adding an additional line (see line "blank").  If we don't add the "blank" line, the "Comments" doesn't appear (see pic); only if we include the "blank" line.

How can we add a column correctly to the Grid?
rayluvsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rayluvsAuthor Commented:
oops, the forgot script and pic:

Private Sub AddColumns()
  Dim nCol As Integer
  With UserForm1.gridItemsFound
    .Redraw = False
    'This setups the Header of the Grid
    'first columns header will be adjusted while code is running
    .AddColumn vKey:="Date", sheader:="Date", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=60
    .AddColumn vKey:="Project", sheader:="Project", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=300
    .AddColumn vKey:="Subject", sheader:="Email", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=300
    .AddColumn vKey:="Task", sheader:="Task", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=200
    .AddColumn vKey:="Type", sheader:="Type", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=100
    .AddColumn vKey:="Dept.", sheader:="Dept", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=100
    .AddColumn vKey:="Comments", sheader:="Comments", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=100
    .AddColumn vKey:="blank", sheader:="blank", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=True, lcolumnwidth:=10
    .Redraw = True
  End With
End Sub

Open in new window


LastColumnProblem
0
Chris Raisin(Retired Analyst/Programmer)Commented:
Chris here

Yes, I noticed that too at my end.

The "quick" workaround you have performed is the correct one.

I will investigate the code I have already supplied to you and get back to you.

Cheers
Chris
0
rayluvsAuthor Commented:
Thanx
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

eemitCommented:
Hi Ramante,

1)
According to vbAccelerator - SGrid 2.0 Documentation:
The row-text column is used to display text and/or icons which stretch across multiple columns
in the grid. The Row-Text column renders below the standard columns. If you are using one,
the row-text column must always be the last column in the grid.

With Code you posted you schould get Error:
"Cannot add a second row text column to the grid".

change:
bRowTextColumn:=True
in each Column to:
bRowTextColumn:=False

2)
If you nead a Row-Text column, add one after Column "Comments" and set it's bRowTextColumn:=True
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris Raisin(Retired Analyst/Programmer)Commented:
Ramante is not using version 2 of the Grid yet, so that error does not occur.
(We will move onto Grid2 later).

I am the original coder for Ramada and I am currently investigating the reason.

Stand By....
0
rayluvsAuthor Commented:
Correct!  Worked

Thank you!
0
rayluvsAuthor Commented:
Didn't read your last entry.  Ok with Grid2 later on
0
Chris Raisin(Retired Analyst/Programmer)Commented:
Ok, Ramnante, that slipped by me :-)

I have amended my code at this end too so I can work on your other questions now.

Note that I have seperated the "Column Indexing" now into a seperate subroutine. This will make calls to that subroutine easier should we need it.

Have you added the "ID" column in yet (hidden) ?

It is needed to allow the user interaction with the email item directly from your Grid.


Cheers
Chris

Private Sub AddColumns()
  Dim nCol As Integer
  Dim OCols As Columns
  Dim ocol As Column
  With UserForm1.gridItemsFound
    .Redraw = False
    'first columns header will be adjusted while code is running
    .AddColumn vKey:="SearchType", sheader:="", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=False, lcolumnwidth:=400
    .AddColumn vKey:="Task", sheader:="Task", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=False, lcolumnwidth:=10
    .AddColumn vKey:="Type", sheader:="Type", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=False, lcolumnwidth:=10
    .AddColumn vKey:="From", sheader:="From", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=False, lcolumnwidth:=10
    .AddColumn vKey:="To", sheader:="To", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=False, lcolumnwidth:=10
    .AddColumn vKey:="Email", sheader:="Email", eAlign:=ecgHdrTextALignLeft, bRowTextColumn:=False, lcolumnwidth:=10
    .AddColumn vKey:="ID", sheader:="ID", bRowTextColumn:=False, lcolumnwidth:=20, bVisible:=False
    .ColumnOrder("SearchType") = GetSetting(Application.Name, "Setup", "ColOrder" + CStr(nCol), 1)
    .ColumnWidth("SearchType") = GetSetting(Application.Name, "Setup", "ColWidth" + CStr(nCol), 400)

    For nCol = 2 To .Columns
      .ColumnOrder(nCol) = GetSetting(Application.Name, "Setup", "ColOrder" + CStr(nCol), nCol)
      .ColumnWidth(nCol) = GetSetting(Application.Name, "Setup", "ColWidth" + CStr(nCol), 100)
    Next
    SetColIndexes

    .Redraw = True
    
  End With

End Sub

Private Sub SetColIndexes()
  ReDim lColIndex(UserForm1.gridItemsFound.Columns)
  On Error Resume Next ' Because some columns may have been deleted through the UI
  With UserForm1.gridItemsFound
    lColIndex(i_PROJECT) = .ColumnIndex("SearchType")
    lColIndex(i_SUBJECT) = .ColumnIndex("SearchType")
    lColIndex(i_TASKS) = .ColumnIndex("Tasks")
    lColIndex(i_TYPE) = .ColumnIndex("Type")
    lColIndex(i_FROM) = .ColumnIndex("From")
    lColIndex(i_TO) = .ColumnIndex("To")
    lColIndex(i_EMAIL) = .ColumnIndex("Email")
  End With
  On Error GoTo 0
End Sub

Open in new window

0
rayluvsAuthor Commented:
Please explain the additional lines in the routine AddColumns():

    For nCol = 2 To .Columns
      .ColumnOrder(nCol) = GetSetting(Application.Name, "Setup", "ColOrder" + CStr(nCol), nCol)
      .ColumnWidth(nCol) = GetSetting(Application.Name, "Setup", "ColWidth" + CStr(nCol), 100)
    Next

Open in new window

0
Chris Raisin(Retired Analyst/Programmer)Commented:
Oops!

You last question slipped by me and I have only just noticed it!

What the function "GetSetting" does is pick up from the Registry the stored "Column Orders" amd Column Widths" for each column which should be saved in your code somewhere (usually in the "Unload" method of a form or in the closing code just as your VBA code finished.

The code should like something like this:

      With UserForm1.gridItemsFound
         For nCol = 2 To .Columns
             SaveSetting  Application.Name, "Setup",  _
                                 "ColOrder" + CStr(nCol), .ColumnOrder(nCol)
             SaveSetting  Application.Name, "Setup", _
                                 "ColWidth" + CStr(nCol), .ColumnWidth(nCol)
         Next
      End With

Open in new window


You may now close this question if all is OK.

Cheers
Chris
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.