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

Looping through a subform records

Good evening all i am trying to loop through a subform records and i need it to display the selected value from each of the records eg:
record 1 prod# 2
record 2 prod# 5
record 3 prod# 3

so in the above senario it would loop 3 times and each time output 2 then 5 then 3. Currently my code will loop through 3 times but constantly output just the first value(2) attached is the code any help would be much appriceated
Expand|Select|Wrap|Line Numbers
  1. Set rs = Me.[sqlOrderDetails subform].Form.RecordsetClone
  2.  
  3. Do While Not rs.EOF
  4.  
  5. prod# = Me.Form![sqlOrderDetails subform]!ProdID
  6. Debug.Print prod#
  7.  
  8. rs.MoveNext
  9.  
  10. Loop
  11.  
  12. Set rs = Nothing
Aug 21 '12 #1

✓ answered by TheSmileyCoder

As rabbit has allready explained, line 5 of your code you are reference the values stored in the form, instead of the recordsetCLONE.
Expand|Select|Wrap|Line Numbers
  1. prod# = rs!ProdID
should work, assuming ProdID is the name of the FIELD in the underlying recordset.

4 10681
Rabbit
12,516 Expert Mod 8TB
That's because you're setting your variable to the value on the form. Not the value in the recordset.
Aug 21 '12 #2
TheSmileyCoder
2,322 Expert Mod 2GB
As rabbit has allready explained, line 5 of your code you are reference the values stored in the form, instead of the recordsetCLONE.
Expand|Select|Wrap|Line Numbers
  1. prod# = rs!ProdID
should work, assuming ProdID is the name of the FIELD in the underlying recordset.
Aug 21 '12 #3
Thanks for your help Rabbit and TheSmileyCoder
Aug 22 '12 #4
TheSmileyCoder
2,322 Expert Mod 2GB
Your welcome. Glad to be of service.
Aug 22 '12 #5

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

Similar topics

2
by: Deano | last post by:
Hi, I was just setting up a test system on a client's machine yesterday and as ever noticed a few problems. One that has thrown me is to do with the order of records in a subform (datasheet...
1
by: phaddock4 | last post by:
Being fairly inexperienced at Access 2000, i've been reading many posts here for the last several days, and testing myself to find the best approach to do the following in A2K: SET UP: I have...
2
by: manning_news | last post by:
Using A2K. I've got a database with client info and each client has a subform which contains types of income and the amount they each receive. The record source of the subform is a cartesian...
1
by: Terri | last post by:
I'm summing subform records in a control on a main form. I have a control in the subform footer called TotalAmount with the control source =Sum(). On my mainform control I reference this control...
1
by: jmarr02s | last post by:
Is it possible to limit the number of Subform records using MS Access 2003? That is, my end users want the capability of entering up to 12 records on their subform. Is that possible? ...
3
by: paquer | last post by:
On my Main form I have a Command Button that opens a Subform in order to create a new Subform record. At this point I want the subform to show only the new record being created. Not all the...
6
by: Otis492 | last post by:
Hello, I have been struggling with this for a while. I am working on a rather simple database for claims in Access 2003. I have a table called claims that has a primary key field called Claim #. ...
0
by: jwbird | last post by:
I have a main form with multiple Subforms that are all displaying Datasheet information related to the Main form record. When I make changes/adds to the records(s) in the subform and tab to another...
1
by: xraive | last post by:
I have a problem with this. Currently I am trying Allen's code and i am not successful. Current Design Table1 (Main Form) TravelID (PK) ApprovedBY EntreredBy BudgetCode ExpenseCode
2
by: Gavin Sequeira | last post by:
Hi. I have a Main form with a Subform. My Main form generates an ID and some info is passed to the subform alongwith the ID. Lets say some changes are made to the mainform, this info is then added to...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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,...
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...

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.