none
ADODB.recordset issues RRS feed

  • Question

  • I am debugging some Project 2010 add-ins. One of them hass  a Type Mismatch error (compiling error) on a subroutine by highlighting the the first line of the sub's definition (for example, "Sub ThisIsSubroutine()" is highlighted). For some reason,part of an array declaration is highlighted as though it was manually highlighted: ReDim vArray(fgrs.recordcount-1, 1) [the '-' is highlighted]. This add-in worked fine when the file was on another computer. Could ADODB.recordset have some issue on my computer?

    This is the same file that was on both computers. Nothing substantial should be different between them, code- and module-wise.

    Note: I should also point out that the recordCount property is used in the code. There's a greater-than-0 check performed on it before the error. So recordCount is a value that can be read, yet no operations can be done on it? Could it also be a Windows 7 issue?


    Wednesday, October 1, 2014 11:18 PM

All replies

  • Hi Mr. Christopher Lee,

    Did you add the Microsoft ActiveX Data Objects reference?

    Go to Tools > Reference and make sure a Microsoft ActiveX Data Objects reference is checked there.

    Hope this helps

    Thursday, October 2, 2014 6:49 AM
  • @Toon Microsoft ActiveX Data Objects 2.5 Library is checked. I have a colleague who has the same reference checked and the tool on the file runs fine on his computer.
    Thursday, October 2, 2014 4:39 PM
  • You should be on version 2.8. That's been out for many years now.

    From memory, recordcount does not get populated sometimes until the end of the recordset is reached. So do a .movelast then .movefirst. RecordCount is read only.

    You could also try cLng(fgrs.recordcount) to force correct type or cInt(fgrs.recordcount) if the count is never going to exceed 32,000

    Can you try compiling the code on a different PC again?


    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

    Thursday, October 2, 2014 8:10 PM
    Moderator
  • @Rod I compiled it on two different PCs and it worked. They didn't even use ".movelast" then ".movefirst". I went back to the file on my computer, swapped 2.5 for 2.8, and it's still not working. Forcing recordcount to be a Long or Int results in a Syntax error. I'm not trying to alter recordcount, I just need to read the value.
    Thursday, October 2, 2014 9:31 PM
  • If it doesn't work only on your PC, then try repairing Project's installation. Try also getting someone else to logon to Your PC and see if it works for them. If it does, you need to reset your profile.

    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

    Thursday, October 2, 2014 11:44 PM
    Moderator