472,980 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,980 software developers and data experts.

Error Message After Inserting a "rs.edit" command



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
1 2822
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Aarono Brown | last post by:
I've seen this question asked a couple times in this forum but never answered, so I guess my hopes aren't too high, but: I'm running > mysql Ver 12.21 Distrib 4.0.14, for pc-linux (i686) ...
9
by: bajopalabra | last post by:
hi session("myVar") = rs.getRows( ) don't work when number of records is greater than 10 does anybody know WHY ??? is it a Session object limitation ??? thanks
0
by: Lauren Wilson | last post by:
The error does not have an error number. It's not even a normal Access error message box. Hope someone has some insight to this problem. I have a form that contains a large (5" x 4") text box...
0
by: Kyle Blaney | last post by:
Is there a way to control how the "Edit->Advanced->Format Selection" command formats long lines? In particular, I want the command to indent long lines differently than new scope. By default, the...
0
by: San Diego Guy | last post by:
Hi all! I have Datagrid. Within that datagrid I have a drop down list that I set up some values in (a "collection") I set up an edit command column on the datagrid and wrote simple code to get...
2
by: Nalaka | last post by:
Hi (I am using visual studio 2005 beta 2) I have a simple asp.net data grid, with a edit (update and cancel) set. When the button mode is link, it works fine. But when the button mode is...
0
by: den 2005 | last post by:
Hi everybody, I am not familiar using Gridview, I created a Gridview with Edit Command Button, but when I click the update Command button this error message below is displayed, what and where is...
2
by: Parasyke | last post by:
Please help.... I have a form that I successfully add records to that I want to copy and turn into a form for editing records from that same table (It is imperitive that it be done this way, rather...
1
by: Benny Ng | last post by:
Dear All, Now I met one problem in the development of my one application. I have one ASP.NET page. It's for disply the information of customer. But now I have one new requirement. It's to...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.