Error Message After Inserting a "rs.edit" command

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kosmös Pollard

    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.EditMod e 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.EditMod e 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
    DaysToCompletio n() As Long" -- I have changing this to "Private Sub
    DaysToCompletio n()" 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 DaysToCompletio n() As Long

    'Opening tblContracts as recSet1
    Dim con1 As ADODB.Connectio n
    Dim con2 As ADODB.Connectio n
    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 "tblContrac ts", 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
    '"tblWhateverYo urTableNameIs", con1 which means
    'connection1 and then to open a field in that recordset you type
    'recSet1.Fields ("fieldname" ))
    x = 0

    recSet1.MoveFir st
    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.EditMod e
    recSet2.Fields( "DateDifference ") = UntilCompletion
    recSet2.Update
    recSet1.MoveNex t
    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 ***
  • Tom van Stiphout

    #2
    Re: Error Message After Inserting a "rs.edit&q uot; command

    On 19 Dec 2006 14:06:02 GMT, Kosmös Pollard <j248@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.EditMod e 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.EditMod e 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
    >DaysToCompleti on() As Long" -- I have changing this to "Private Sub
    >DaysToCompleti on()" 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 DaysToCompletio n() As Long
    >
    'Opening tblContracts as recSet1
    Dim con1 As ADODB.Connectio n
    Dim con2 As ADODB.Connectio n
    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 "tblContrac ts", 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
    '"tblWhateverYo urTableNameIs", con1 which means
    'connection1 and then to open a field in that recordset you type
    'recSet1.Fields ("fieldname" ))
    x = 0
    >
    recSet1.MoveFir st
    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.EditMod e
    recSet2.Fields( "DateDifference ") = UntilCompletion
    recSet2.Update
    recSet1.MoveNex t
    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 ***

    Comment

    Working...