-
August 6th, 2012, 05:07 AM
#1
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
-
August 6th, 2012, 07:18 AM
#2
Re: Add items to LynxGrid not the same type error?
I don't know lynxgrid, but I think the error is this:
The .CellText() property, as the name would suggest, is a text, meaning it is a string data type.
Presumably the IDCode field is numeric and an automatic datatype conversion does not occur.
So try an explicit consversion like
Code:
.CellText(lRow, 0) = CStr(rsstaff!IDCode)
Except, if you have really a BLANK between rssstaff and !IDCode (as your post shows it) then it wouldn't work at all.
Last edited by WoF; August 6th, 2012 at 07:20 AM.
-
August 6th, 2012, 10:30 PM
#3
Re: Add items to LynxGrid not the same type error?
LynxGrid like as Listview but it've got interface nice than listview. I also tried your way but still the above error
-
August 7th, 2012, 08:11 AM
#4
Re: Add items to LynxGrid not the same type error?
You have several spaces in your code that should not be there.
Code:
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
You have a space between the tablename and the . for each field selection which is incorrect.
You have a space between each rsstaff and ! which should not be there.
On your select statement there is no need to specify the table name for each field since you are only selecting from one table.
Anyway remove the invalid spaces and give it a try.
Always use [code][/code] tags when posting code.
-
August 8th, 2012, 07:41 AM
#5
Re: Add items to LynxGrid not the same type error?
That's what I hinted, too. But then I thought, if these spaces where really there, an error must have already occured in the rsstaff.open statement. The code wouldn't even get to the line where the type mismatch occurred.
-
August 13th, 2012, 11:14 PM
#6
Re: Add items to LynxGrid not the same type error?
this error is not rsstaff.open, you see attach file lynxgrid3a.rar http://www.crocko.com/6F151357267441...lynxgrid3a.rar
-
August 14th, 2012, 08:57 AM
#7
Re: Add items to LynxGrid not the same type error?
If you are going to post code please post the actual code. What you have posted has several spaces that should nto be there and the code would not work as a result. If you do not post the actual code then there is no way of knowing what you have doen in the "actual code"
As for the error Type Mismatch means that you are trying to add data that is not the right type for the object. Usually happens when you try to add non numeric data to a numeric field or non date value to a date field.
Check you field types, using the debugger check the data in the var on the line where the error occurrs.
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|