473,396 Members | 1,693 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,396 software developers and data experts.

Cycle through records

Hey all,

I'm trying to get access (through VBA) to cycle through all the records in a form and perform a task for each one that has something in a text box. I think I know how to get it to do what I want, I just don't know how to reference a record in my For each... statement. Here is the code I have:

Dim Record As Recordset

For Each Record In Forms!frmRFIattach

If Not Forms!frmRFIattach!Attachment = "" Then
'Do some stuff
End If

Next Record

Any help is appreciated!!
Oct 20 '06 #1
1 2232
jimatqsi
1,271 Expert 1GB
Here is a portion of some code I posted in another message:

Notice that "rs" is a handle to a record set which is opened with OpenRecordSet.
That handle is how you can reference anything having to do with that recordset, whether it is a field found in the records of the recordset, or the end-of-file condition or anything else. In this sample, [Item], [Warehouse] and [OnHand] are all fields in my records of the recordset.

This code again is only a portion of a program, it's not supposed to look complete.

Jim

Expand|Select|Wrap|Line Numbers
  1. Set db = CurrentDb
  2.  
  3.     Set rs = db.OpenRecordset("ItemWarehouse")
  4.     Onhandqty = 0
  5.     On Error GoTo Loopend
  6.     rs.MoveFirst
  7.  
  8.     strFind = "Item='" & CStr(ItemNbr) & "'"
  9.     rs.FindFirst (strFind) ' first occurrence of this item in itemwh file
  10.  
  11. LoopItems:
  12.     While (Not (rs.EOF))
  13.     If rs.NoMatch Then GoTo Loopend
  14.     If rs![Item] <> ItemNbr Then GoTo NextItem
  15.     ' If rs![Warehouse] <> "9301" And rs![Warehouse] <> "3405" Then GoTo NextItem
  16.     If rs![Warehouse] = "PCR" Then GoTo NextItem
  17.     Counter = Counter + 1
  18.     Onhandqty = Onhandqty + rs![OnHand]
  19.     If Counter > 1 Then GoTo Loopend  'don't bother looking after we found both warehouses
  20. NextItem:
  21.     rs.FindNext (strFind)
  22.  
  23.  
Oct 20 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: mike | last post by:
I'd like to have the options for my cycle loaded from the config file if possible. So far I haven't been able to find the right syntax or an example, any ideas? ie <code> *** config file ***...
8
by: John Ortt | last post by:
Hi there, I have written the following code to colour cycle the background in one of my forms. The problem is it only cycles from Black to Red and then reverts back to Black. Does anyone...
1
by: JJ | last post by:
Hi All, I have created a oledbdataadapter/OledbConnection and dataset. I would like to cycle through all records that the dataset has to implant into a treeview as nodes. How do i do this? ...
6
by: jim | last post by:
Hi All, I like to know the life cycle of an ASP .NET Application( incudieng server application, such as .NET Web Service). That means from initialization to fully running and how to reboot it or...
1
by: Martin Williams | last post by:
I'm trying to cycle through the child records of a current customer, in order to calculate a total. Here is my code so far: sub GetTransactionTotal() dim drArray() as datarow dim intCount,...
6
by: Ilia Chipitsine | last post by:
Dear Sirs, I want to dump all databases, but separately each database in its own file, not all databases in one single file as pg_dumpall does. How can I implement that ? Cheers, Ilia...
5
by: cvisal | last post by:
Hi all Im working on productivity calculations (Time calculations) and need some help in coding. Database Tool:MS-Access 2003. The general operator punch-in time is 5:30 AM and the punch-out...
0
by: jer006 | last post by:
Hi, This is more of a general question... I have a series of stored procedures (chain of procedures) in db2 on an AS400 which are executed from a SQL Server Job, when I execute the job manually...
10
by: fdu.xiaojf | last post by:
Hi all, I have the following code: for i in generator_a: # the first "for" cycle for j in generator_b: if something_happen: # do something here ..., I want the outer cycle to break break
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.