VBA Error 'Method or Data Member Not Found

  • Thread starter Thread starter Ian
  • Start date Start date
I

Ian

I am using VBA code to update an existing record in a
table from the data entered on a form.

The code used works fine in another database but in this
one the error message 'Compile Eror: Method or Data
Memeber Not Found' appears at the 'CurrTab.Edit' line in
the code below.

Any help would be much appreciated.

Dim CurrDb As Database
Dim CurrTab As Recordset

Set CurrDb = CurrentDb
Set CurrTab = CurrDb.OpenRecordset("tblCases")

Do Until CurrTab.EOF
If CurrTab("CaseID") = Me!CaseID Then
CurrTab.Edit
CurrTab("ReasonUpheld") = Me!ReasonUpheld
CurrTab("Fund") = Me!Fund
CurrTab.Update 'Updates the record
 
Try this instead: -

Function Example()
Dim MaxError As Integer
Dim CurrDb As Database
Dim CurrTab As Recordset
Set CurrDb = CurrentDb
Set CurrTab = CurrDb.OpenRecordset
("tblCases",dbOpenDynaset)
CurrTab.MoveFirst
While Not CurrTab.EOF
MaxError = StrComp(CurrTab!CaseID,Me.CaseID,vbTextCompare)
If MaxError = 0 Then
CurrTab.Edit
CurrTab!ReasonUpheld = Me.ReasonUpheld
CurrTab!Fund = Me.Fund
CurrTab.Update 'Updates the record
End If
CurrTab.MoveNext
Wend
Set CurrTab = Nothing:Set CurrDb = Nothing
End Function

CODE LIES BETWEEN FUNCTION STATEMENTS, DO NOT INCLUDE
FUNCTION STATEMENTS IN YOUR CODE.

Problem with your code: -

When using "Me" on a local object, the syntax Me.TextBox1
is to be used, not Me!TextBox1.
RecordSet References are NEVER to be enclosed in inverted
commas: -
CurrTab("ReasonUpheld")
should be like CurrTab!ReasonUpheld

HTH

Tony C.
 
Back
Top