Hello all. I have a series of flexgrids that I am trying to set up for text entry. I am using Osborne's VB From The Ground UP as my reference manual, and I am using the style described in this book to float a textbox over the flexgrid. However, this style is designed for one and only one flexgrid.

I have one textbox (txtFloater) and 12 flexgrids (flxFullAP, flxFullA, flxFullAM, etc.). I want to use a variable to point to the correct flexgrid, so that the code for all the flexgrid methods is the same except for the first line of flxXXX_EnterCell (where I would set the 'pointer' variable to represent the current flexgrid in use). My instinct is to do the following:

VB Code:
  1. Private ThisFlx As Control 'This variable will represent whichever flxgrid we are using.
  2.  
  3. Private Sub PositionFloater()
  4. txtFloater.Left = ThisFlx.CellLeft + ThisFlx.Left
  5. txtFloater.Top = ThisFlx.CellTop + ThisFlx.Top
  6. txtFloater.Width = ThisFlx.CellWidth
  7. txtFloater.Height = ThisFlx.CellHeight
  8. txtFloater.Visible = True
  9. txtFloater.SetFocus
  10. End Sub
  11.  
  12. Private Sub flxFullAP_EnterCell()
  13. ThisFlx = flxFullAP 'This line would change for each _EnterCell() method
  14. txtFloater.Text = ThisFlx.Text
  15. PositionFloater
  16. End Sub
  17.  
  18. Private Sub Form_Load()
  19. ThisFlx = flxFullAP 'This sets the top-left flexgrid as the jumping-off point...
  20. Set txtFloater.Font = ThisFlx.Font
  21. Show
  22. ThisFlx.Col = 0
  23. ThisFlx.Row = 0
  24. PositionFloater
  25. End Sub
  26.  
  27. Private Sub txtFloater_Change()
  28. ThisFlx.Text = txtFloater.Text
  29. End Sub
  30.  
  31. Private Sub txtFloater_KeyDown(KeyCode As Integer, Shift As Integer)
  32. 'This allows implementation of Excel-standard cell navigation
  33. Select Case KeyCode
  34.    Case Is = vbKeyUp:      ThisFlx.Row = ThisFlx.Row - 1 Mod ThisFlx.Rows
  35.    Case Is = vbKeyDown:    ThisFlx.Row = ThisFlx.Row + 1 Mod ThisFlx.Rows
  36.    Case Is = vbKeyRight:   ThisFlx.Col = ThisFlx.Col + 1 Mod ThisFlx.Cols
  37.    Case Is = vbKeyLeft:    ThisFlx.Col = ThisFlx.Col - 1 Mod ThisFlx.Cols
  38. End Select
  39. End Sub
Obviously, this is isn't working for me. There are several other ways that I could do it, but I'm sure there's a way this approach can work. I simply don't know the correct syntax for representing controls with variables. So my question is:

How do I represent a control with a variable.
The key line here is ThisFlx = flxFullAP. When this line executes, I get the following error: Object variable or With block variable not set.

Any help would be greatly appreciated. Thanks everybody!