Click to See Complete Forum and Search --> : recordset.Absoluteposition problem
piersk
10-21-2003, 11:27 AM
I'm trying to do the whole alternate colours row thing.
I get the absoluteposition of a record (recordset.absoluteposition) and I know that it's an integer cos I have used CInt and have checked it using vartype(). I then call a function like this: fcnCellColour(recordset.absoluteposition) and the function fcnCellColour is like this:Function fcnCellColour(strInput)
strInput = strInput Mod 2
IF strInput = 1 THEN
fcnCellColour = "#cccccc"
ELSE
fcnCellColour = "#ffffff"
END IF
End Function
However, I keep getting the error message:Microsoft VBScript runtime error '800a000d'
Type mismatch: 'fcnCellColour'
/forum/addtogroup.asp, line 159
Anyone got any theories why this should be?
rdoekes
10-21-2003, 02:06 PM
You call it as a sub, but you define it as a function with a return value.
Response.Write fcnCellColour(recordset.absoluteposition)
for instance will give you the expected outcome.
Or
<td bgcolor="<% = fcnCellColour(recordset.absoluteposition)%>">
Hope this helps.
-Rogier Doekes
piersk
10-21-2003, 02:08 PM
Sorry, I should have made it clearer. I already have <% = fcnCellColour(recordset.absoluteposition)%> in there.
rdoekes
10-21-2003, 02:18 PM
and which line is line 159?
piersk
10-21-2003, 02:21 PM
The line that has the <td bgcolor="<% = fcnCellColour(recordset.absoluteposition)%>"> in it.
rdoekes
10-21-2003, 02:52 PM
Based on your description I mocked up the following code, and I reveice no errors, with nice alternating cell background colors.
<table>
<%
Set oCnn = Server.CreateObject("ADODB.Connection")
oCnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=z:\test\test.mdb;" & _
"User Id=;" & _
"Password="
Set oRs = Server.CreateObject("ADODB.RecordSet")
oRs.CursorLocation = 3 'adUseClient
oRS.Open "SELECT * FROM tbl_test", oCnn
If Not oRs.EOF Then
Do While Not oRs.EOF
%>
<tr>
<td bgcolor="<% = fcnCellColour(oRs.AbsolutePosition)%>">
<% = oRS.Fields(0).Value%></td>
</tr>
<%
oRs.MoveNext
Loop
Else %>
<tr><td>No records found</td></tr>
<%
End If
oRs.Close
oCnn.Close
Set oRs = Nothing
Set oCnn = Nothing
Function fcnCellColour(strInput)
strInput = strInput Mod 2
IF strInput = 1 THEN
fcnCellColour = "#cccccc"
ELSE
fcnCellColour = "#ffffff"
END IF
End Function
%>
</table>
In other words, you must be doing something else. Maybe the recordset?
piersk
10-22-2003, 03:16 AM
Hi,
the code for the recordset looks like this: set rsCommittee = server.createobject("ADODB.Recordset")
rsCommittee.Activeconnection = strForumDSN
rsCommittee.Source = "select * from contacts where " & request.querystring("committee") & " = True order by LASTNAME"
rsCommittee.CursorType = 1
rsCommittee.CursorLocation = 3
rsCommittee.LockType = 1
rsCommittee.Open()
The recordset does actually work because I can get the member details out fine, and when I output the actual number that corresponds to the absolute position I get an integer.
rdoekes
10-22-2003, 03:41 AM
very strange indeed.
Again I tested your code and I do not receive any errors.
Could you attach the code of the entire page to a reply?
I will take have a look and see what I can dig up.
-Rogier Doekes
piersk
10-22-2003, 04:07 AM
As requested...
rdoekes
10-22-2003, 04:24 AM
Is this the entire page?
Don't see the function anywhere.
piersk
10-22-2003, 04:28 AM
The function is called on line 23 of the code I gave you. The actual code for the function is in a seperate file but is exactly as i posted earlier.
rdoekes
10-22-2003, 04:35 AM
and where do you include this file?
Don't see that in the code
piersk
10-22-2003, 04:39 AM
/me bangs head against wall
Of course!! I'm so stupid. I hadn't included the file.
Your last post reminded me.
Doh!
Thank you for your help.
rdoekes
10-22-2003, 04:41 AM
Be careful you don't get a concussion :-)
my pleasure,
-Rogier Doekes