Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2004
    Posts
    14

    Unanswered: Rs.MoveFirst Error

    Hi,

    I'm getting the error:

    "You cannot add or change a record because a related record is required in the table 'TableName'. -2147217887 "

    This is the code


    If (Rs.EOF = True) Then 'There is no plate data yet (no records)
    Rs.AddNew 'Then add one
    Rs("PlateSeriesID") = ThisSeries
    Rs("PlateID") = 1
    End If

    Rs.MoveFirst ' <------Error HERE'


    Any idea?

    thanks.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    before you worry about possible referential integrity errors, you might find a
    rs.update
    useful after you have set the values.

    i use a slightly different syntax from yours - my version would be:

    If (Rs.EOF = True) Then 'There is no plate data yet (no records)
    Rs.AddNew 'Then add one
    Rs!PlateSeriesID = ThisSeries
    Rs!PlateID = 1
    Rs.update
    End If

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Jun 2004
    Posts
    14
    Thanks.

    Unfortunatelly Rs.Update is giving me the same error!!!???

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    then it is time to worry about referential integrity.
    you need to give us a hint about your table scheme.

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Jun 2004
    Posts
    2

    Smile

    Hi,
    If you are using dao then use recordset type as "dbOpenDynamic"


    Set rs = connection.OpenRecordset("Stock", dbOpenDynamic)

    if you are using ado then use recordset type "adopenDynamic"

    set rs=connection.Open sSQL, adoConn, adOpenDynamic

    then save will not give the error...

    please check it out ...

    regrads,
    eby

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    "You cannot add or change a record because a related record is required in the table 'TableName'. -2147217887 "
    ..from the first post.

    izy
    currently using SS 2008R2

  7. #7
    Join Date
    Jun 2004
    Posts
    14
    Quote Originally Posted by izyrider
    then it is time to worry about referential integrity.
    you need to give us a hint about your table scheme.

    izy
    thanks a ton izy, you were right.

    was trying to save a record that didn't have a required record in another table.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •