Update subform's data from main form button -- A2007

J

JimS

I want to set a column to false on every record in a subform's recordset.
Here's the code. I tried using the command "Set rst=...." and got an error
message. Then I removed the word "Set" and got "invalid use of property"...

Private Sub btnLockAll_Click()
Dim rst as new recordset
rst=Me.sfmPOLine.Form.RecordsetClone
rst.movefirst
While not rst.eof
rst!POLineAllowImportUpdate=False
rst.Update
rst.MoveNext
Wend
End Sub
 
J

Jeanette Cunningham

Hi Jim,
I usually use this method.


Private Sub btnLockAll_Click()
Dim rst As DAO.Recordset

Set rst=Me.sfmPOLine.Form.RecordsetClone

rst.movefirst
While not rst.eof
rst!POLineAllowImportUpdate=False
rst.Update
rst.MoveNext
Wend
rst.Close
Set rst = Nothing
End Sub


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
B

Beetle

Modify your code like this;

Dim rst As Recordset
Set rst = Me.sfmPOLine.Form.RecordsetClone
rst.MoveFirst
While Not rst.EOF
rst.Edit
rst!POLineAllowImportUpdate = False
rst.Update
rst.MoveNext
Wend

rst.Close
Set rst = Nothing


OR - a slightly simpler version;

With Me.sfmPOLine.Form.RecordsetClone
.MoveFirst
While Not .EOF
.Edit
!POLineAllowImportUpdate = False
.Update
.MoveNext
Wend
End With
 
J

JimS

Sean, thanks for the advice. I'll try it later today. The error I got was on
the "set" statement, which looks identical to yours... why would it work?
(I'll try it anyway...)
 

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