checkbox in a runtime grid fails inside a bigger app

Hi,
I created a "simple" run-time grid. When I tested it out as a stand alone routine it works well. When I tried to integrate into a bigger app, where the READ EVENTS is initiated higher up in the program, and it uses many custom baseclasses under VFP 8 the checkbox generates the error: Error with CHK1 - Value : Data type mismatch.  
Note: I also tried this using a separate DEFINE for chk1 and it didn't help

Bonus question – how do you prevent the “delete” column from appearing in the grid – that little half-column on the left edge that you can click to delete a record.

Here is the abbreviated code:
******************************************
SELECT ac_tracknos
PUBLIC go_tracknolist
=l_doform()
RETURN

******************************************
FUNCTION l_doform

go_tracknolist = CREATEOBJECT("tracknolist")
go_tracknolist.show()

DEFINE CLASS tracknolist as Form
  WINDOWTYPE = 1  &&modal
  visible = .t.
  ShowWindow = 1
  Caption = "Tracking Numbers"
  Height = 305
  Width = 640
  fn_botrow = 258

  PROCEDURE init()
    WITH THIS
      .ADDOBJECT('cmdCancel', 'cCancel' )
      .cmdCancel.VISIBLE = .T.
      .AddObject("grid1","cgrid")
      .grid1.visible = .t.
    ENDWITH
  ENDPROC

ENDDEFINE
DEFINE CLASS cgrid AS Grid
   Left = 12
   Top = 10
   Width = 615
   Height = 245
   Visible = .T.
   RowHeight = 25
   ColumnCount = 2
   Column1.ControlSource ="seltd"
   Column2.ControlSource ="trackno"
   Column1.Sparse = .F.
  Procedure Init
     THIS.Column1.Width = 52
     THIS.Column2.Width = 175
     &&replace column1 with a checkbox
     THIS.Column1.AddObject("chk1", "checkbox")
     THIS.Column1.CurrentControl = "chk1"
     THIS.Column1.chk1.Visible = .T.
     THIS.Column1.chk1.Caption = ""
  ENDPROC

ENDDEFINE

DEFINE CLASS cCancel AS COMMANDBUTTON
  CANCEL = .T.  
  CAPTION = "\<Cancel"
  HEIGHT = 25

  PROCEDURE init()
    this.TOP = thisform.fn_botrow + 18
    this.LEFT = thisform.WIDTH - this.WIDTH - 5
  ENDPROC
     
  PROCEDURE CLICK
    USE IN "ac_tracknos"  
    go_tracknolist.RELEASE
  ENDPROC
ENDDEFINE
******************************************
jinfeldPresidentAsked:
Who is Participating?
 
pcelbaCommented:
No, there is no way to populate the form from your code. At least I don't know it. But this form is very simple, so it is 10 minutes of work.

BTW, the answer to your bonus question is  Grid.DeleteMark property (.T. = display Delete column).
0
 
Olaf DoschkeSoftware DeveloperCommented:
This kind of grid will only work for recordsources having a logical field in the first field, otherwise of course you get the error "data type mismatch" A Checkbox cannot dislpay text, numbers (despite 0 and 1 also work like .F. and .T.)

The deletion column is called deletion mark, grid.deletemark = .f. get's rid of that column.

Bye, Olaf.
0
 
jinfeldPresidentAuthor Commented:
The first column is logical - that is why it works when I run it outside the larger app.

The table, ac_tracknos has 2 fields:
seltd L(1)
trackno C(50)
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
pcelbaCommented:
If there is no error but something like this happen in more complex environment then your only chance is to try to program it different way... The only possibility seems to be to create this small form visually in Form designer and call it by DO FORM instead of CREATEOBJECT.

The first attempt, of course, should be to test it under the latest VFP version (VFP9 SP2). Maybe it will work.

And the last possibility is ask Microsoft for a paid hotfix.

A new FoxPro version should also come. But not from Microsoft and not this year.
0
 
jinfeldPresidentAuthor Commented:
Thanks,
Is there a way to use the run-time code to populate a form or do I need to do it manually?
0
 
pcelbaCommented:
Sorry, I did not read Olaf's answer till the end. He answered the bonus question already.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.