By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,506 Members | 2,275 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,506 IT Pros & Developers. It's quick & easy.

Error Message After Inserting a "rs.edit" command

P: n/a


Hey guys, I'm rather new to access and can not seem to figure out what
is wrong with this code I will post below...but first...it was working
perfectly fine before I added this:

recSet2.Edit
recSet2.Fields("DateDifference") = UntilCompletion
recSet2.Update

As was suggested by a helpful friend at TheScripts

My Access suggests I use recSet2.EditMode instead

either way I end up with an error message

If I use recSet2.Edit then my error message is "Method or data member
not found (Error 461)"

If I use recSet2.EditMode then my error message is "Invalid use of
Property"

but although it is the .Edit or .EditMode that get's highlighted as if I
highlighted it myself (in blue), it is the declaration of the function
that get's highlighted in yellow which is "Public Function
DaysToCompletion() As Long" -- I have changing this to "Private Sub
DaysToCompletion()" and that made no difference

And now for the full code (No need to read the commentary, I was adding
it to remind myself exactly what I was doing):

Option Compare Database

Public Function DaysToCompletion() As Long

'Opening tblContracts as recSet1
Dim con1 As ADODB.Connection
Dim con2 As ADODB.Connection
Dim recSet1 As ADODB.Recordset
Dim recSet2 As ADODB.Recordset
Set con1 = CurrentProject.Connection
Set con2 = CurrentProject.Connection
Set recSet1 = New ADODB.Recordset
Set recSet2 = New ADODB.Recordset
recSet1.Open "tblContracts", con1
recSet2.Open "tbldtdiff", con2
Dim x As Long

'Declaring UntilCompletion as the amount of days until completion
Dim UntilCompletion As Long

'Looping until EOF (until the last record for EndDate in
tblContracts...so
'someone else would have declared recSet1.Open
'"tblWhateverYourTableNameIs", con1 which means
'connection1 and then to open a field in that recordset you type
'recSet1.Fields("fieldname"))
x = 0

recSet1.MoveFirst
Do Until recSet1.EOF
' End Date must be in quotes or will not work
UntilCompletion = DateDiff("d", Date, recSet1.Fields("EndDate"))
Debug.Print UntilCompletion
recSet2.EditMode
recSet2.Fields("DateDifference") = UntilCompletion
recSet2.Update
recSet1.MoveNext
x = (x + 1)
Loop

'Clearing recSet1 and Con1 (Connection1) and recSet 2 and Con1
recSet1.Close
recSet2.Close
con1.Close
con2.Close
Set con1 = Nothing
Set con2 = Nothing
Set recSet1 = Nothing
Set recSet2 = Nothing

End Function

Any help would be much appreciated!

Cheers,

Kosmös

*** Sent via Developersdex http://www.developersdex.com ***
Dec 19 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 19 Dec 2006 14:06:02 GMT, Kosmös Pollard <j2**@brandeis.eduwrote:

..Edit is used for DAO recordsets, and is not needed for ADO
recordsets.
The difference between .Edit and .EditMode can be found in the help
file. Don't become a tinkerer. Write code you understand.

-Tom.
>

Hey guys, I'm rather new to access and can not seem to figure out what
is wrong with this code I will post below...but first...it was working
perfectly fine before I added this:

recSet2.Edit
recSet2.Fields("DateDifference") = UntilCompletion
recSet2.Update

As was suggested by a helpful friend at TheScripts

My Access suggests I use recSet2.EditMode instead

either way I end up with an error message

If I use recSet2.Edit then my error message is "Method or data member
not found (Error 461)"

If I use recSet2.EditMode then my error message is "Invalid use of
Property"

but although it is the .Edit or .EditMode that get's highlighted as if I
highlighted it myself (in blue), it is the declaration of the function
that get's highlighted in yellow which is "Public Function
DaysToCompletion() As Long" -- I have changing this to "Private Sub
DaysToCompletion()" and that made no difference

And now for the full code (No need to read the commentary, I was adding
it to remind myself exactly what I was doing):

Option Compare Database

Public Function DaysToCompletion() As Long

'Opening tblContracts as recSet1
Dim con1 As ADODB.Connection
Dim con2 As ADODB.Connection
Dim recSet1 As ADODB.Recordset
Dim recSet2 As ADODB.Recordset
Set con1 = CurrentProject.Connection
Set con2 = CurrentProject.Connection
Set recSet1 = New ADODB.Recordset
Set recSet2 = New ADODB.Recordset
recSet1.Open "tblContracts", con1
recSet2.Open "tbldtdiff", con2
Dim x As Long

'Declaring UntilCompletion as the amount of days until completion
Dim UntilCompletion As Long

'Looping until EOF (until the last record for EndDate in
tblContracts...so
'someone else would have declared recSet1.Open
'"tblWhateverYourTableNameIs", con1 which means
'connection1 and then to open a field in that recordset you type
'recSet1.Fields("fieldname"))
x = 0

recSet1.MoveFirst
Do Until recSet1.EOF
' End Date must be in quotes or will not work
UntilCompletion = DateDiff("d", Date, recSet1.Fields("EndDate"))
Debug.Print UntilCompletion
recSet2.EditMode
recSet2.Fields("DateDifference") = UntilCompletion
recSet2.Update
recSet1.MoveNext
x = (x + 1)
Loop

'Clearing recSet1 and Con1 (Connection1) and recSet 2 and Con1
recSet1.Close
recSet2.Close
con1.Close
con2.Close
Set con1 = Nothing
Set con2 = Nothing
Set recSet1 = Nothing
Set recSet2 = Nothing

End Function

Any help would be much appreciated!

Cheers,

Kosmös

*** Sent via Developersdex http://www.developersdex.com ***
Dec 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.