473,396 Members | 2,109 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.

Object Variable question

Just moving up from Access 97 and trying 2K. I am used to using the
FindFirst method of the RecordsetClone object in order to do form
navigation with a combo box. I notice that the wizard in 2K writes the
following code in order to accomplish this...

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.Find "[req_no] = " & Str(Me![Combo98])
Me.Bookmark = rs.Bookmark

Set rs = Me.Recordset.Clone

My questions are;

1. Why dim the recordset as Object rather than as ADODB.Recordset?
2. Why not use rs.close and/or Set rs = nothing

If if was me doing this I would write...

On Error GoTo EH

Dim rst As ADODB.Recordset

Set rst = Me.Recordset.Clone
rst.Find "req_no = " & Str(Me!cboRequestCode)
Me.Bookmark = rst.Bookmark
rst.Close

SeeYa:
Set rst = Nothing
Exit Sub

EH:
MsgBox Err.Number & " - " & Err.Description
Resume SeeYa

Comments??

yamafopa!
Nov 12 '05 #1
2 1658
On 31 Jan 2004 19:58:46 -0800, ya******@yahoo.com (yamafopa) wrote:

see comments in-line.
-Tom.
Just moving up from Access 97 and trying 2K. I am used to using the
FindFirst method of the RecordsetClone object in order to do form
navigation with a combo box. I notice that the wizard in 2K writes the
following code in order to accomplish this...

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.Find "[req_no] = " & Str(Me![Combo98])
Me.Bookmark = rs.Bookmark

Set rs = Me.Recordset.Clone

My questions are;

1. Why dim the recordset as Object rather than as ADODB.Recordset? Sloppy programming, or late binding. Note that with A2000 for the
first time ADO is the default, rather than DAO,

2. Why not use rs.close and/or Set rs = nothing Sloppy programming. You're better off closing objects explicitly.

If if was me doing this I would write...

On Error GoTo EH

Dim rst As ADODB.Recordset

Set rst = Me.Recordset.Clone
rst.Find "req_no = " & Str(Me!cboRequestCode)
Me.Bookmark = rst.Bookmark
rst.Close

SeeYa:
Set rst = Nothing
Exit Sub

EH:
MsgBox Err.Number & " - " & Err.Description
Resume SeeYa

Comments??

yamafopa!


Nov 12 '05 #2
This is a guess on my part, but I know that from A2K you can "Save as
previous version".
This code will run without change in A97.
If the declaration were specific to ADO (default for A2K) or DAO (default
for A97), there would be more problems moving between versions.
In fact, this code will run under any combination of references to ADO
and/or DAO.

As for closing rs, I've repeatedly seen the admonition:
If YOU open it, YOU should close it.
You're not opening rs - just setting it to point to an existing recordset.
So there's no need for you to close it.
And since it's declared local to your procedure, it will go out of scope
anyhow.

HTH
- Turtle

"yamafopa" <ya******@yahoo.com> wrote in message
news:86*************************@posting.google.co m...
Just moving up from Access 97 and trying 2K. I am used to using the
FindFirst method of the RecordsetClone object in order to do form
navigation with a combo box. I notice that the wizard in 2K writes the
following code in order to accomplish this...

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.Find "[req_no] = " & Str(Me![Combo98])
Me.Bookmark = rs.Bookmark

Set rs = Me.Recordset.Clone

My questions are;

1. Why dim the recordset as Object rather than as ADODB.Recordset?
2. Why not use rs.close and/or Set rs = nothing

If if was me doing this I would write...

On Error GoTo EH

Dim rst As ADODB.Recordset

Set rst = Me.Recordset.Clone
rst.Find "req_no = " & Str(Me!cboRequestCode)
Me.Bookmark = rst.Bookmark
rst.Close

SeeYa:
Set rst = Nothing
Exit Sub

EH:
MsgBox Err.Number & " - " & Err.Description
Resume SeeYa

Comments??

yamafopa!

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

100
by: E. Robert Tisdale | last post by:
What is an object? Where did this term come from? Does it have any relation to the objects in "object oriented programming"?
26
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized...
12
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
7
by: Arpan | last post by:
The .NET Framework 2.0 documentation states that An Object variable always holds a pointer to the data, never the data itself. Now w.r.t. the following ASP.NET code snippet, can someone please...
10
by: Pramod | last post by:
Hello to all of you, I want to know that what's the use to create static object. Thanks You Pramod Sahgal
0
by: zman77 | last post by:
EDIT: -- forgot to mention... I am using Visual Studio 2005, on Win XP, on an intel machine Hi. This is my first post, though I've "lurked" for a while because I find these forums very helpful....
32
by: Joe | last post by:
I am just starting to use Object Oriented PHP coding, and I am seeing quite often the following (this example taken from a wiki): $wakka =& new Wakka($wakkaConfig); What exactly is the =&, and...
15
by: TonyV | last post by:
Hey all, for debugging purposes, I'd like to be able to access an object's instance name from within the object class. For example, I'd like to be able to do something like this: ...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
45
by: =?Utf-8?B?QmV0aA==?= | last post by:
Hello. I'm trying to find another way to share an instance of an object with other classes. I started by passing the instance to the other class's constructor, like this: Friend Class...
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...
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
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...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.