What does part of this code do.

  • Thread starter Thread starter John Michael
  • Start date Start date
J

John Michael

I know what this code is supposed to do.
Look up a record based on the field txtCardNumberSearch

Dim rs As Object
Set rs = Me.Recordset.Clone
rs.findfirst strFieldname & " =" & Str(Nz(Me![txtCardNumberSearch], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark


I am curious as to what this line does and if I have it in the right place
since I have the code below after it.
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
I may want to put an else statement after if to trap the event.

I use this code after the above code:
If rs.NoMatch Then
Me.Section(acDetail).Visible = False
txtCardNumberSearch = Null
MsgBox "Member VIP Card Number Not Found.", , "Search Failure!"
txtCardNumberSearch.SetFocus
' SpecialEffectEnter
Else
If boolIsLoginAllowed() = True Then
Me.Section(acDetail).Visible = True
Me!VarSessionDirty.Value = False
SpecialEffectExit
cmdEnter.Enabled = True
cmdEnter.SetFocus
End If


after it in case there is no match, but what would cause an End of file to
be reached.

Thanks
John Michael
 
The only thing I can think of that would cause EOF to be reached by doing a
search would be if the recordset your created a clone of didn't have any
records in the first place (in other words, you were at EOF before you
searched). Normally, that line would read,

If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark

But, I don't know that even that check is needed. If you haven't done
anything else to move the clone or the original recordset since the clone
was created, then they should both have the same Bookmark already and
setting Me.Bookmark won't do anything. Basically, it all comes down to what
else you may be doing, if anything.
 

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

Back
Top