steph wrote in message
<11**********************@u72g2000cwu.googlegroups .com> :
Hi,
I'm a bit of an access-dummy, and i suppose this problem of mine has
a rather simple solution, but nevertheless i'm not sure i see it at
the moment.
I've got an access-form in datasheet-view and i want to iterate over
it's records and set some values according to our business logic.
This action should be triggered by the user via a button. I suppose i
need to access the record-set the form is based on doing something
like:
With FormRecordSet
If .EOF = False Then
FormRecordSet("column1")="WhateverValueIWantToSetI tTo"
.MoveNext
End With
But, how do I access the form's record-set? And is there a better
solution to this problem?
Thanks for any input!
stephan
I would probably rather execute an action query (update) with the same
filter or where clause as the form in stead. Then requery the form.
I wouldn't be surprised, though, if a couple of smallish alterations of
your code, would work - some air code
dim FormRecordSet as form
set FormRecordSet = me!frmSubFormControl.Form.Recordsetclone
With FormRecordSet
' an .eof test and .movefirst here?
Do While not .EOF
.Edit
.Fields("YourFieldName").Value = "WhateverValueIWantToSetItTo"
.Update
.MoveNext
Loop
' .movefirst ' ?
End With
set FormRecordSet = nothing
Note - the referencing when assigning the recordsetclone - you say this
is a datasheet, then I assume it is a subform, and that the button
you're pressing, is within a main form. Then you need to refer through
the main form, using the subform control name, which can differ from
the name in the database window.
--
Roy-Vidar