UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> findfirst and error 3251    
 
   
chuckf1
post Dec 7 2004, 03:15 PM
Post#1



Posts: 12
Joined: 18-February 04



I'm using .findfirst in a recordset from table tblPersonnel to point to a found recrd where Name_Last = string.
. ** is the error-line
The code is below. I'm getting a 3251 error "operation is not supported for this type object"
Note: tblPersonel table is empty.
hat's the problem here.
Public rstPersonnel As DAO.Recordset
Set rstPersonnel = CurrentDb.OpenRecordset("tblPersonnel")
With rstPersonnel
' Find first record satisfying search string. Exit
' loop if no such record exists

** .FindFirst "[Name_last] = '" & m.UserProperties("NameLast") & "'"

MsgBox ("txtStudentID: " & m.UserProperties("txtStudentID"))

If .NoMatch Then 'Add a record
MsgBox "No records found with " & m.UserProperties("NameLast") & "txtStudentID " & m.UserProperties("txtStudentID") & "."
.AddNew
!NameFirst = Trim(m.UserProperties("NameFirst"))
rstPersonnel!NameLast = Trim(m.UserProperties("NameLast"))
!txtPersonnel_ID = Trim(m.UserProperties("txtStudentID"))
.Update
Else 'Update record
MsgBox "Found match with " & m.UserProperties("NameLast") & "txtStudentID " & m.UserProperties("txtStudentID") & "."
.Edit
!NameFirst = Trim(m.UserProperties("NameFirst"))
.Update
End If
End With
Thanks in advance,
Chuck
Go to the top of the page
 
xteam
post Dec 7 2004, 10:22 PM
Post#2


UtterAccess VIP
Posts: 3,667
Joined: 14-November 03
From: Toronto, ON


Set rstPersonnel = CurrentDb.OpenRecordset("tblPersonnel", dbOpenDynaset)
Go to the top of the page
 
chuckf1
post Dec 8 2004, 11:46 PM
Post#3



Posts: 12
Joined: 18-February 04



Great - that solved the problem.
Thanks,
huck
Go to the top of the page
 
xteam
post Dec 9 2004, 12:00 AM
Post#4


UtterAccess VIP
Posts: 3,667
Joined: 14-November 03
From: Toronto, ON


You're welcome !
Go to the top of the page
 
mishej
post Dec 9 2004, 12:07 AM
Post#5


Retired Moderator
Posts: 11,289
Joined: 25-September 02
From: Milwaukee, WI


Just a clarification for readers about the problem. If you don't specify the type parameter for the OpenRecordset call then Access does this:
If you open a Recordset in a Microsoft Jet workspace and you don't specify a type, OpenRecordset creates a table-type Recordset, if possible. If you specify a linked table or query, OpenRecordset creates a dynaset-type Recordset. In an ODBCDirect workspace, the default setting is dbOpenForwardOnly.
If you are always using a TableType (dbOpenTable) then you can use the .Seek method instead of .FindFirst. My understanding is that the .Seek method takes advantage of an existing index on the specified field and would be faster. But you can only use .Seek on RecordSets of type dbOpenTable. Thus if the Recordset type could be a table, query or SQL then the dbOpenDynaset would be a better choice and thus the .FindFirst is the way to go. This is from the on-line help for .FindFirst:

Locates the first, last, next, or previous record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Jet workspaces only).
Go to the top of the page
 
roalddeswart
post Jul 28 2014, 05:54 AM
Post#6



Posts: 8
Joined: 9-July 14



After 10 years, this treat still helps people to solve this issue :-)
Thanks for your answer!!!
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    22nd July 2018 - 06:00 AM