#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    104
    Rep Power
    5

    Add items to LynxGrid not the same type error?


    I put the records in a database with access to LynxGrid Type mismatch error, can you see help my code wrong ?

    Private Sub Form_Load()
    Dim lRow As Integer

    'set list columns
    With listEntries
    .Redraw = False
    .AddColumn "ID Code", 50 '0
    .AddColumn "Full Name", 150 '1
    .AddColumn "Adress", 260 '2
    .AddColumn "Telephone", 70 '3

    .Redraw = True
    .Refresh
    End With

    strSQL = "SELECT Tabstaff .IDCode, Tabstaff .FullName, Tabstaff .Adress, Tabstaff .Telephone FROM Tabstaff ;"

    rsstaff .Open strSQL, DataCustomers, adOpenKeyset, adLockOptimistic
    rsstaff .MoveFirst
    listEntries.Redraw = False
    listEntries.Clear
    While Not rsstaff .EOF
    With listEntries
    lRow = .ItemCount
    .AddItem
    .CellText(lRow, 0) = rsstaff !IDCode ' This was the type mismatch error, if this line is rem by single quotes, then the next line will error
    .CellText(lRow, 1) = rsstaff !Fullname
    .CellText(lRow, 2) = rsstaff !Adress
    .CellText(lRow, 3) = rsstaff !Telephone
    End With
    rsstaff .MoveNext
    Wend
    listEntries.Redraw = True
    listEntries.Refresh
    rsstaff .Close

    End Sub
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,453
    Rep Power
    4539
    Almost always a type mismatch with database data code is because a field value in your recordset is NULL when you expected the column to have a value.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    104
    Rep Power
    5
    Originally Posted by Doug G
    Almost always a type mismatch with database data code is because a field value in your recordset is NULL when you expected the column to have a value.
    I try to lock the bottom line

    '.CellText(lRow, 0) = rsstaff !IDCode
    '.CellText(lRow, 1) = rsstaff !Fullname
    '.CellText(lRow, 2) = rsstaff !Adress
    '.CellText(lRow, 3) = rsstaff !Telephone

    and assign directly but still above error
    .CellText(lRow, 0) = 2355

    or
    .CellText(lRow, 1) = "Peter Pan"
  6. #4
  7. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,453
    Rep Power
    4539
    You should be able to inspect the values contained in the recordset with the vb debugger.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    104
    Rep Power
    5
    Originally Posted by Doug G
    You should be able to inspect the values contained in the recordset with the vb debugger.
    I tested it but could not be

IMN logo majestic logo threadwatch logo seochat tools logo