RecordsetClone - Trying to understand.

S

SpookiePower

I have a few questions to this code that I'm trying to
understand.

strFind = " [kundenummer] = " & Me.[tbsogkunde]
With Me.RecordsetClone
.FindFirst strFind
If .NoMatch = False Then
Me.Bookmark = .Bookmark
Else
Beep
End If
End With


I have found that Me.RecordsetClone is -
"Create a clone of the forms recordset"
But what does it means ? It is the word "recordset" that I dont know
the real meaning of. I think of it as the one single recordset that is
displayed in the form, but this single "recordset" only holds one
customer, so why search through this single recordset......I think.
But my guess is that it takes a copy of the complete table
(Record source) connecting to the table and then search through
that copy to find the right customer...I hope.


..Findfirst -
As I can find out it then search through the copy using the criteria
strFind.

I guess that this line - If .NoMatch = False Then
means - If something is found...then ?

But this one Me.Bookmark = .Bookmark
I can't understand.

Someone who can answer some of my questions ?



www.photo.activewebsite.dk
 
D

Douglas J Steele

Normally, the Record Source for a form will be a recordset that contains
multiple rows, even if you're only showing details from one row at a time.

The RecordsetClone lets you look at all of the rows that are associated with
the current record source.

What that particular bit of code is trying to do is determine whether
there's at least one row in the form's records source for which the field
kundenummer contains whatever number is in control (or field) tbsogkunde on
the form. If there is, it sets a bookmark for the first row found. If not,
it beeps.
 
D

Dirk Goldgar

SpookiePower said:
I have a few questions to this code that I'm trying to
understand.

strFind = " [kundenummer] = " & Me.[tbsogkunde]
With Me.RecordsetClone
.FindFirst strFind
If .NoMatch = False Then
Me.Bookmark = .Bookmark
Else
Beep
End If
End With


I have found that Me.RecordsetClone is -
"Create a clone of the forms recordset"
But what does it means ? It is the word "recordset" that I dont know
the real meaning of. I think of it as the one single recordset that is
displayed in the form, but this single "recordset" only holds one
customer, so why search through this single recordset......I think.
But my guess is that it takes a copy of the complete table
(Record source) connecting to the table and then search through
that copy to find the right customer...I hope.


.Findfirst -
As I can find out it then search through the copy using the criteria
strFind.

I guess that this line - If .NoMatch = False Then
means - If something is found...then ?

But this one Me.Bookmark = .Bookmark
I can't understand.

Someone who can answer some of my questions ?

A Recordset is a code object that contains a set of records, and
provides methods to operate on them and navigate among them. Of that
set of records, only one at a time is "current"; that is, only one is
the record that will be operated on.

A form has a recordset, which is loaded by querying its recordsource
(table or query). The form displays the current record from its
recordset, for you to view, update, or delete.

The form's RecordsetClone method makes a copy of the form's recordset
and returns a reference to it, for your code to act upon. This copy is
itself a recordset.

The recordset object's FindFirst method searches the recordset from top
to bottom to find the first record that matches the specified criteria.
If a matching record is found, that record becomes the recordset's
current record.

Recordset objects have a Bookmark property that is a pointer to the
current record. It's not a record number, but it can be used to
identify a specific record in the recordset. You can also move to a
specific record in the recordset by setting its Bookmark property to a
*compatible* value. Normally, only bookmarks that were saved from that
same recordset are compatible, but the bookmarks of a recordset's clone
are compatible, because the clone is an exact duplicate of the original
recordset.

The form also has a Bookmark property. This is just the Bookmark
property of the form's recordset.

Therefore, the line
Me.Bookmark = .Bookmark

sets the form's Bookmark to the Bookmark of its RecordsetClone, and thus
moves the form to the record that is current in the recordsetclone.
That is the record that was found by the FindFirst method.
 
S

SpookiePower

Thanks to both of you for your help :)

So a bookmark is a pointer, that points to the row in the recordset
where the search found a match. And then by saying -
Me.Bookmark = .Bookmark
the current row/record is displayed on the form ?
 
D

Dirk Goldgar

SpookiePower said:
Thanks to both of you for your help :)

So a bookmark is a pointer, that points to the row in the recordset
where the search found a match. And then by saying -
Me.Bookmark = .Bookmark
the current row/record is displayed on the form ?

Right.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top