473,698 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cycle through records

2 New Member
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!frmRFIatt ach

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

Next Record

Any help is appreciated!!
Oct 20 '06 #1
1 2242
jimatqsi
1,276 Recognized Expert Top Contributor
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
3263
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 *** color1="#eeeeee" Color2="#dddddd"
8
1981
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 have any idea what's causing this?
1
1520
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? This is a win app. Thanks, JJ
6
2636
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 shut it down. Including how to establish the running environment( current working folder, ...etc) for each ASP .NET application. Because in my ASP .NET application, there are a lot of modules. Some were developed by using VC#, others using...
1
929
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, intCurrentCustomer as integer dim dblSubTotal, dblTax, dblTotal as double intCurrentCustomer = me.bindingcontext(dataset1, "Customer").position + 1
6
2265
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 Chipitsine
5
6512
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 time is 2:00PM. The Break times are 1) 9:30 AM to 9:45 AM 2) 11:00AM to 11:30 AM 3) 12:30PM to 12:45 PM
0
1499
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 during the day (or when I execute the stored procedures in db2 on the AS400 directly) everything completes successfully. However when the procedures are executed on its scheduled cycle at 3am in the morning it fails most every morning with a...
10
2088
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
8675
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9029
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6521
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.