Connecting Tech Pros Worldwide Help | Site Map

Recordset.Index gives error in XP

RBohannon
Guest
 
Posts: n/a
#1: Nov 13 '05
I've developed a database in Access 2000 on Windows 2000. I have been
asked to put the database on a machine running Windows XP. I copied
the database onto the XP machine with some data already in it.
Everything seemed to be working correctly, until I tried to import new
data.

New data is imported into the database from a floppy disk. To prevent
duplicate entries, I have a boolean function called Exists which uses
the Seek method of Recordset to search for a value already existing in
a table. If the value is in the table, Exists returns True, and False
otherwise.

This function works correctly on my Windows 2000 machine, but on the XP
machine I get the following error message:
Error 3251: Operation is not supported for this type of object

Below is my code for the Exists function with a comment showing where
the error occurs. My references include Microsoft DAO 3.6 Object
Library.

I would greatly appreciate if anyone could tell me why this error is
occurring on the XP machine and how I can correct it. I would even
take suggestions for an alternate way of doing the same thing.

'==========================================
Public Function Exists(strRS As String, _
strIndex As String, _
strTarget As String) As Boolean

' checks if an indexed value exists in a given recordset
' returns true is value exists, false otherwise
' strRS = recordset to search
' strIndex = field to search on
' strTarget = value being searched for

Dim db As dao.Database
Dim RS As dao.Recordset

Set db = CurrentDb
Set RS = db.OpenRecordset(strRS)

RS.Index = strIndex ' <== ERROR OCCURS HERE
RS.Seek "=", strTarget

If RS.NoMatch = True Then
Exists = False
Else
Exists = True
End If

RS.Close

End Function
'==========================================

Randy A. Bohannon
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Recordset.Index gives error in XP


OK, so I thought the problem was a result of the app being developed on
Windows 2000 and then being moved to XP, and there was some version conflict
with somethingorother. But I tried this on my XP laptop at home, and it
works fine.

I'm still curious if anyone has any idea about what the problem could be,
but I'm going to use DCount instead of the Recordset methods. I just need
to wait until I'm back in the office to see if DCount gives me any trouble
on the other machine.

Thanks in advance.

Randy


Allen Browne
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Recordset.Index gives error in XP


DCount() should be fine.

The Seek method (DAO) works only for recordsets of type dbOpenTable.
That type applies only to local tables, not attached tables which open as
dbOpenDynaset by default.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Randy A. Bohannon" <bohannon@rr.com> wrote in message
news:NiEFd.26326$Xs6.4937@twister.nyroc.rr.com...[color=blue]
> OK, so I thought the problem was a result of the app being developed on
> Windows 2000 and then being moved to XP, and there was some version
> conflict
> with somethingorother. But I tried this on my XP laptop at home, and it
> works fine.
>
> I'm still curious if anyone has any idea about what the problem could be,
> but I'm going to use DCount instead of the Recordset methods. I just need
> to wait until I'm back in the office to see if DCount gives me any trouble
> on the other machine.[/color]


RBohannon
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Recordset.Index gives error in XP


Thank you for the explanation. That makes perfect sense - I split the
application on the XP machine at work, but not on my laptop.

Allen Browne wrote:[color=blue]
> DCount() should be fine.
>
> The Seek method (DAO) works only for recordsets of type dbOpenTable.
> That type applies only to local tables, not attached tables which[/color]
open as[color=blue]
> dbOpenDynaset by default.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Randy A. Bohannon" <bohannon@rr.com> wrote in message
> news:NiEFd.26326$Xs6.4937@twister.nyroc.rr.com...[color=green]
> > OK, so I thought the problem was a result of the app being[/color][/color]
developed on[color=blue][color=green]
> > Windows 2000 and then being moved to XP, and there was some version[/color][/color]
[color=blue][color=green]
> > conflict
> > with somethingorother. But I tried this on my XP laptop at home,[/color][/color]
and it[color=blue][color=green]
> > works fine.
> >
> > I'm still curious if anyone has any idea about what the problem[/color][/color]
could be,[color=blue][color=green]
> > but I'm going to use DCount instead of the Recordset methods. I[/color][/color]
just need[color=blue][color=green]
> > to wait until I'm back in the office to see if DCount gives me any[/color][/color]
trouble[color=blue][color=green]
> > on the other machine.[/color][/color]

Closed Thread