Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use "Find" methods on Replication ID fields

Status
Not open for further replies.

murad5

Technical User
Sep 12, 2003
61
US
Hi All,

I'm trying to find a particular replication ID in a field, but I get the error message

Run time error 3251
Operation not supported for this type of object

Here is the code:

Function find_record() As Boolean
Dim db As Database
Dim rsMaster As Recordset
Set db = CurrentDb
Set rsMaster = CurrentDb.OpenRecordset("T-Promos")
' This line is where the problem occurs
rsMaster.FindFirst "[Promo_ID]={guid" _
& Forms!frmpromomaster!Promo_ID.Text & "}"
find_record = Not (rsMaster.NoMatch)
Set db = Nothing
Set rsMaster = Nothing
End Function

Any suggestions to get around this gratefully received?
 
Try this instead ...

Function find_record() As Boolean
Dim db As Database
Dim rsMaster As Recordset
Set db = CurrentDb
Set rsMaster = CurrentDb.OpenRecordset("T-Promos")
If Not (rsMaster.EOF And rsMaster.BOF) Then
rsMaster.FindFirst "[Promo_ID]={guid" _
& Forms!frmpromomaster!Promo_ID.Text & "}"
find_record = Not (rsMaster.NoMatch)
Else
'no records found
End If
Set db = Nothing
Set rsMaster = Nothing
End Function

tiny

Perfection is Everything
If it worked first time we wont be here!
 
Hi Tiny,

Thanks for the suggestion, but I'm afraid I'm still getting the same error message...
 
Dim db As DAO.Database
Dim rsMaster As DAO.Recordset

I believe you have both ADO and DAO, but ADO has a higher priority.
Your recordset is evaluated as an ADODB.Recordset, which...indeed...does not support FindFirst.


HTH

[pipe]
Daniel Vlas
Systems Consultant

 
Hi Daniel, I checked my references again, and I did have ADO turned off. I tried adding the DAO references, as you suggested, but it doesn't seem to be doing any good. Similar code is working for other data types, it seems the be just replication ids which cause issues. Does anyone now if there are special conditions attached to them?
 
What is this variable -""[Promo_ID]={guid" _ & Forms!frmpromomaster!Promo_ID.Text & "}"
???????

I have got this function to work with my variables and it works ... I just can't figure out what the above variable is?

Function find_record() As Boolean
Dim db As Database
Dim rsMaster As Recordset
Set db = CurrentDb
Dim promo_id_str As String
'unsure of what the variable is
'you may need to correct this "[Promo_ID]={guid" _ & Forms!frmpromomaster!Promo_ID.Text & "}"
promo_id_str = "[Promo_ID]=guidForms!frmpromomaster!Promo_ID.Text"

Set rsMaster = CurrentDb.OpenRecordset("T-Promos", dbOpenDynaset)

rsMaster.FindFirst promo_id_str
If rsMaster.NoMatch Then
MsgBox "No record found."
Else
' Find other matching records.
Do Until rsMaster.NoMatch
Debug.Print Forms!frmpromomaster!Promo_ID.Text ' or anyother field name in the rsMaster recordset
rsMaster.FindNext promo_id_str
Loop
End If

Set db = Nothing
Set rsMaster = Nothing
End Function

Tiny

Perfection is Everything
If it worked first time we wont be here!
 
Thanks for all your help on this one, guys, I appreciate it!

The variable in question is the value of a replication ID held in a text box on the frmPromoMaster. When I try the function changing it to just a normal string (and changing the data) it seems to work fine.

I think I'm going to give this one up as a bad lot. I'm working around it by using queries now anyway, so I guess it doesn't matter so much anymore.

Once again, thanks for all your help!
 
I tried that originally, but it came back with an error saying it was a "Malformed GUID"
 
what is the column property of [Promo_ID]? Integer?

Tiny

Perfection is Everything
If it worked first time we wont be here!
 
The column property is Replication ID...
 
I know this is an older post but I found if someone else stumbles on this as I did try to change the SET statement to:

Set rsMaster = CurrentDb.OpenRecordset("Select * from T-Promos")

It worked for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top