[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Passing a reference to a function on the 'current' record in a recordset

Posted on 2007-10-13
9
Medium Priority
?
173 Views
Last Modified: 2010-04-30
My app is using a module level recordset.

I am looping through each of the records in this recordset.
With each one, I call a function that will do 'something' with the information in each record.

how can I pass a reference to the 'current' record in the recordset to the function?

0
Comment
Question by:scbdpm
  • 5
  • 4
9 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20071644
if the recordset is defined on module level, and the function also, you might consider using no parameter at all.
however, you should pass the recordset variable, it will be on the correct place if you loop in the calling code with the .MoveNext ...
0
 

Author Comment

by:scbdpm
ID: 20071711
angelIII:

How do I do what you suggest: "however, you should pass the recordset variable, it will be on the correct place if you loop in the calling code with the .MoveNext ..."
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 20071731
assuming your function would looks like this:

Private Sub YourJob ( r as adodb.recordset )
   
  'handle the current record of the record set

End Sub



in your main function, you do like this:

dim r as adodb.recordset
set r = new adodb.recordset
r.open SQL, connection

while not r.eof
    YourJob r
    r.MoveNext
wend


r.close
set r = nothig



0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:scbdpm
ID: 20071756
I've adapted your code to my app.

However, I am getting a 'Type Mismatch' error on the line : YourJob r
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20071760
that is only possible if you omitted, in either places the "adodb." from the "adodb.recordset"

0
 

Author Comment

by:scbdpm
ID: 20071915
Actually I had:

YourJob (r)


instead of:
YourJob r
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20071937
glad you found that difference.
do you actually know that the () made as difference?

if not, they will actually make that not     r   is  passed, but the default property of r

0
 

Author Comment

by:scbdpm
ID: 20072010
once I removed the (), it ran like clockwork.....

thoughts?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20073044
see my comment above
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question