MarkD
  • MarkD
  • Newbie Topic Starter
2024-10-04T18:53:56Z
Hi,

I'm using modern grid 64 bit v7.50.1049.

Steps to reproduce:
- create empty database
- create empty form
- insert grid named grdTest
- insert button named btnTest.
- code behind:


Private Sub Form_Load()
  Me!grdTest.ColCount = 1
  Me!grdTest.RowCount = 5
  Me!grdTest.CellValue(1, 1) = "one"
  Me!grdTest.CellValue(2, 1) = "two"
  Me!grdTest.CellValue(3, 1) = "three"
  Me!grdTest.CellValue(4, 1) = "four"
  Me!grdTest.CellValue(5, 1) = "five"
End Sub

Private Sub btnTest_Click()
  Dim Sel() As TSelItemInfo
  ' Debug.Print TypeName(Me!grdTest.SelItems.GetArray) ' not supported type
  Sel = Me!grdTest.SelItems.GetArray ' Err 13 type mismatch
End Sub

select any row, press button -> type mismatch.

What am I doing wrong? Probably something very basic... 🙈

Thanks in advance and best regards - Mark
Igor/10Tec
2024-10-07T06:36:14Z
As far as I can tell from looking at your source code, you are using iGrid ActiveX in Microsoft Access. The problem you reported is actually a problem of passing UDTs like TSelItemInfo in arrays that appears in some development environments, including Microsoft Access. It's not a problem of the Modern Edition of iGrid, this problem exists in the Classic Edition too. That's why we added the following paragraph to the help topic describing the iGrid.SelItems.GetArray method:

Not all development environments allow you to use the GetArray method as it returns a typed array. As an alternative, you can use the GetString method of the SelItemsObject instead.

Wayne Phillips, the developer of twinBASIC (the new VB6/VBA compatible development environment we used to compile the modern edition of iGrid), explained why this happens and how to solve the problem. Without excessive details, the problem is the following:

A call to your SelItems GetArray() would be early-bound, however, due to ActiveX wrapping that occurs automatically by hosts such as Access, this call is being made late-bound.

The suggested solution is simple:

Dim igridX As iGrid                ' this makes it early-bound, rather than using
Set igridX = Me!grdTest.Object     ' the Ax late-bound wrappers provided by the host

aV_arr = igridX.SelItems.GetArray  ' this is now an early-bound call to GetArray()

Let us know whether this helps to solve the problem.
MarkD
  • MarkD
  • Newbie Topic Starter
2024-10-08T22:51:58Z
Thanks a lot, that worked now!

(I'd have bet in the original (not shortened) code there would have been exactly what you suggested, but I finally found a Dim Grid As Object...)

Btw: I'm quite sure the code worked before with the classic grid since I'm trying to convert it for 64bit Access.

Thanks again - Mark