473,729 Members | 2,328 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 2246
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
3268
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
1983
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
1521
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
2637
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
930
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
2270
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
6514
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
1502
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
2093
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
8921
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
8763
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
9427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9284
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...
0
6022
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
4528
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2683
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2165
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.