Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issues Converting .edit from MS Access 2003 to MS Access 2010

Status
Not open for further replies.

chris3366

Technical User
Mar 15, 2002
23
US
I had an MS Access database (2003) version running on XP. I have recently upgraded to Windows7 with MS Access 2010. There is some code used that was designed to populate a text field with the data located above, until it reached the next string of text.
Here is the code as it was

Public Sub FillClaims()
Dim rst As Recordset
Dim strClaim As String

Set rst = CurrentDb.OpenRecordset("AutoTableImport")

rst.MoveLast
rst.MoveFirst

strClaim = rst("Claim")

For i = 0 To rst.RecordCount - 1
If IsNull(rst("Claim")) Then
rst.Edit
rst("Claim") = strClaim
rst.Update

End If
strClaim = rst("Claim")
rst.MoveNext
Next i

rst.Close
Set rst = Nothing
Beep
Beep
MsgBox "Fill Claims Done", vbExclamation

End Sub

The error message I get is – Compile Error: Method or data member not found

When I change the data member to EditMode (see below)

Public Sub FillClaims()
Dim rst As Recordset
Dim strClaim As String

Set rst = CurrentDb.OpenRecordset("AutoTableImport")

rst.MoveLast
rst.MoveFirst

strClaim = rst("Claim")

For i = 0 To rst.RecordCount - 1
If IsNull(rst("Claim")) Then
rst.EditMode
rst("Claim") = strClaim
rst.Update

End If
strClaim = rst("Claim")
rst.MoveNext
Next i

rst.Close
Set rst = Nothing
Beep
Beep
MsgBox "Fill Claims Done", vbExclamation

End Sub

I get a new error message-Compile error: Invalid use of property

Any thoughts on how to properly code this in Access 2010 so I can keep the needed functionality?
 
No that code never worked as written, or somehow when you converted it the code got altered

rs.edit
....
rs.update

This allows you to update a recordset. Editmode returns a value indicating what edit mode it is in. This is impossible and has no meaning

rs.editmode
...
rs.update
 
What about this ?
Dim rst As [!]DAO.[/!]Recordset

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yes you should also define your recordsets as shown. But regardless Editmode has absolutely no meaning or use in your code.

rst.EditMode
rst("Claim") = strClaim
rst.Update

to

rst.Edit
rst("Claim") = strClaim
rst.Update
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top