Method not found error

J

Joan

Hi,
I have a subform where on the AfterUpdate event of a control, I edit the
fields of other fields in the recordset of the subform. These fields however
are not on the subform itself. When I run my form, I get a compile error:
"Method or data memeber not found" on the following line:
.Edit

I cannot figure out why I am getting this on my code. Does anyone have any
ideas? Any help would be so appreciated! Below is my code:

Joan


Private Sub txtStore_AfterUpdate()
Dim db As Database
Dim rs As Recordset
Dim stStore As String
Dim dteRetSaleDate As Date
Dim stInvoice As Long
Dim curRetSalePrice As Currency

Set db = CurrentDb
Set rs = db.OpenRecordset("qryInvoiceSubEdit", dbOpenDynaset)

stStore = Me.Store
stInvoice = Me.InvNum
dteRetSaleDate = Me.dteDateSold
curRetSalePrice = Me.SalesPrice

If Me.Returned <> Null Then
With rs
.Edit
!ReturnedStore = stStore
!ReturnedInvoice = stInvoice
!ReturnedSaleDate = dteRetSaleDate
!ReturnedSalePrice = curRetSalePrice
.Update
End With
End If
End Sub
 
S

SteveS

Joan,

I think the problem is in the line

If Me.Returned <> Null Then

Try changing the line to

If Not IsNull(Me.Returned) Then


You should also close the recordset you created and set rs
and db to nothing (clean-up type stuff)

Here is your code with the additions.

--------
Private Sub txtStore_AfterUpdate()
Dim db As Database
Dim rs As Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("qryInvoiceSubEdit",
dbOpenDynaset)

If Not IsNull(Me.Returned) Then
With rs
.Edit
!ReturnedStore = Me.Store
!ReturnedInvoice = Me.InvNum
!ReturnedSaleDate = Me.dteDateSold
!ReturnedSalePrice = Me.SalesPrice
.Update
End With
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
-----------------


HTH

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top