Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2007

Tip: Looking for answers? Try searching our database.

Bookmark comparison

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
swas - 20 Jul 2007 10:22 GMT
Hi,

I don't understand why the following code generates a 'Type mismatch' error:

Dim rs as DAO.recordset
dim varTemp as variant

'(rs opened and moved to a record)

varTemp = rs.Bookmark 'Note a record

'(In later code after moving around recordset)

If rs.Bookmark = varTemp then
   'Confirm on tagged record

   'Code..........

End If

The line 'If rsBookmark = varTemp Then' gives a type mismatch error with the
'=' highlighted.

The reason I am using this line is because as I am processing through the
recordset, I may need to add some new records. Because these added records
are placed at the end of the rs, I need to know what is the first added
record bookmark, otherwise I will 'reprocess' these added records.

So my alternate question is, is this the best method for handling this
situation? To close and re-open the rs each time is to slow. To add a record
then remove it from the recordset would also work (But not delete it from the
table).

I hope this is clear. I can provide more complete code if needed.

Thanks in advance.

swas
Allen Browne - 20 Jul 2007 10:38 GMT
The recordset might not have a current bookmark.

That can happen after adding a new record, deleting a record, moving before
the first record, moving after the last record, using a Find method or Seek
that results in NoMatch, or if the recordset is loaded/filtered such that it
has no records.

Alternatively, the bookmark may be out of date if the recordset has been
reopened, requeried, or reassigned.

After sorting that out, it might be safer to perform a binary comparison
   If StrComp(rs.Bookmark, varTemp, vbBinaryCompare) = 0
since bookmarks are binary data.
Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Hi,
>
[quoted text clipped - 38 lines]
>
> swas
swas - 21 Jul 2007 15:02 GMT
Allen,

Thanks for that.

I definately have a current record, and your StrComp allows the comparison.

Not sure why the comparison I used didn't work, but as usual your help is
appreciated.

swas

> The recordset might not have a current bookmark.
>
[quoted text clipped - 51 lines]
> >
> > swas
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.