473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

iterating over a form's records

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

May 16 '06 #1
5 6536
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
May 16 '06 #2
On Tue, 16 May 2006 17:23:24 +0200, RoyVidar
<ro*************@yahoo.no> wrote:

dim FormRecordset as DAO.Recordset.

Yes, I think a .MoveFirst is warranted at the top of the loop, because
if the subform is selected on a non-first record, the recordsetclone
will be starting there as well.

-Tom.

steph wrote in message
<11**********************@u72g2000cwu.googlegroup s.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.


May 17 '06 #3
Hi,

Thanks for the replies. It worked as expected and I learned a bit, too.

regards,
stephan

May 17 '06 #4
"steph" <st*******@yahoo.de> wrote in
news:11*********************@y43g2000cwc.googlegro ups.com:
Thanks for the replies. It worked as expected and I learned a bit,
too.


But there's no reason to change data by looping through a form's
recordset, unless the changes you make are dependent on complex
considerations that aren't found in the record you're operating on.

This is a point that perhaps got lost in Roy's post, but I can't
stress it enough. Looping through recordsets is something that
should only seldom be done in order to update data. It's sequential
thinking, whereas the efficient method is thinking in sets of data
and using SQL to operate on those sets.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
May 17 '06 #5
I agree with you. But as I said before I'm not very proficient in
access, so I shouldn't leave out a chance to learn something, although
if it's through doing things not the way it ought to be.
For this small problem I had to solve here my solution is now
sufficient - for bigger operations i tend to do things directly in the
database (which is not an access-database).

May 17 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Paxton | last post by:
At the risk of being told "If it ain't broke, don't fix it", my code works, but is ugly. Part of the admin site I'm working on at the moment includes a facility for users to enter Formulations...
3
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60...
1
by: KC | last post by:
Hello, I am using Access 2002. WinXP, Template from MS called Orders Mgmt DB. I have tweaked this DB to work for our small co. It has worked pretty well up until I made the mistake of deleting...
2
by: nettid1 | last post by:
I'm a little new to Access so please bear with me... I have a query in Access consisting of three fields: Account Number, Query ID and Description. I want to have a button on a form that calls...
14
by: Jacko | last post by:
Hi guys, Say I made a SELECT statement to my sql DB that would return 50 rows that I will use a sqldatareader to access. Instead of iterating through each and every row of the datareader, I'd...
25
by: krbyxtrm | last post by:
hello i have this profile for iterating empty vectors: +0.3us (microsecond) on intel pentium 2.4Ghz can this added delay to my application be reduced? i mean near zero delay, its very important....
2
by: David Veeneman | last post by:
Is there a way to iterate the components on a form? I need to determine whether an instance of my custom component (a System.ComponentModel component) is present in a form. I have tried...
3
by: mark blackall | last post by:
Hi all, I am new to vb.net and I am trying to use the vb.net components, rather than relying on the VB6 compatibility stuff with which I am more familiar. However, I seem to have fallen at...
0
by: SBMpy | last post by:
Instead of itereating through my half-million plus records, I'm looking for a way to query the records and return a subset of records. Q: Does dbfpy have that functionality? Q: Or is there a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.