[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

Run-time error 3021 retrieving bookmark from listview object in Visual Basic 6 compiled program.

I am using Visual Basic 6 (SP6) on Microsoft Windows 98 2nd Edition with Microsoft DAO 3.6 Object Library.
Inside the source I open a recordset in dynaset mode and assign it to a global variable:
   '
   Global gRsPage as Recordset
   Set gRsPage = gDb.OpenRecordset(strSQL, dbOpenDynaset)
   '
Then I show all records by a ListView Object, assigning at each row a single record data:
   '
   lngRow = 0
   '
   While Not gRsPage.EOF
      lngRow = lngRow +1
      lvwPage.ListItems.Add lngRow, , gRsPage(0)      'Numeric data, ie '93999393'
      '
      lvwPage.ListItems(lngRow).Tag = gRsPage.Bookmark
      '
      gRsPage.MoveNext
   Wend
   '
When the operator click on a ListView row, inside the ItemClick event I get the selected record and show the other record fields:
   '
   Private Sub lvwPage_ItemClick(ByVal Item as MSComctlLib.ListItem)
      '
      If Len(Item.Tag) > 0 Then              
         gRsPage.BookMark = Item.Tag
         '
         *** ShowAllData(gRsPage(1), gRsPage(2), etc.) routine ***
         '
      End If
      '
   End Sub
   '
By Visual Basic IDE interface all run OK but:
   1. when I use the COMPILED program (.EXE);
   2. when, on the first time, I click on the SECOND listview row (the first listview row is selected automatically);
   3. the "Run-time error '3021'. No currend record.' appears when the "gRsPage.BookMark = Item.Tag" instruction is executed.

This error never is shown:
   1. on interpreted version (by IDE);
   2. on listview contains alfanumeric data  ("Mr. Smith") and not only numeric data ("93999393");
   3. clicking on listview rows different from the second (first, third, etc).
0
softheart
Asked:
softheart
  • 6
  • 5
1 Solution
 
aikimarkCommented:
1, is it possible that the recordset is getting rebuilt?

2. you need to use the Item parameter to get to the tag:

Example:
gRsPage.BookMark = lvwPage.ListItems.Item(Item.Index).Tag
0
 
softheartAuthor Commented:
1. is it possible that the recordset is getting rebuilt?
No, because the recordset is built only in a specific point, before the routine that shows its data. Moreover this is a program that is used at least 5 years.

2. you need to use the Item parameter to get to the tag.
I am not according with you but I have used your modifications.
The result do not change: 'run-time error 3021'.

Thanks.
0
 
softheartAuthor Commented:
I would like underline that the error appears ONLY on compiled program.
I suppose that it could be an listview object error.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
aikimarkCommented:
3. There was a change in the DAO Bookmark property, probably beginning with 3.6.  It used to be a string and then became a variant data type, due to an internal change to a byte array.

You will need to do a pair of conversions into Unicode and out of Unicode, since the .Tag property is a string.

Example:
lvwPage.ListItems(lngRow).Tag = StrConv(gRsPage.Bookmark, vbUnicode)

...
gRsPage.BookMark = StrConv(lvwPage.ListItems.Item(Item.Index).Tag, vbFromUnicode)
0
 
softheartAuthor Commented:
The indication sounds good but, unfortunately, it do not run.
0
 
aikimarkCommented:
now we need to look at environmental issues...

4. Are you running the compiled program on the same PC as your development PC?  If not, did you do a proper installation/setup of the program?

5. There are maintenance issues for both Win98 and VB to consider.  Are all the service packs installed on both development and target systems?
0
 
aikimarkCommented:
Although not part of your problem, if you have a large recordset, you might consider using the Key instead of the Tag property.  It eliminates two of the listview control references.  Also, you don't need the lngRow variable any more.

Example:
Do Until gRsPage.EOF
   lvwPage.ListItems.Add , StrConv(gRsPage.Bookmark, vbUnicode), gRsPage(0)
Loop
...

gRsPage.BookMark = StrConv(Item.Key , vbFromUnicode)
0
 
aikimarkCommented:
Ignore my last comment.  I had only fed relatively small recordsets when I'd posted my comment.  The creation of the hash table more than offsets the reduction of listview control references and makes it SLOWER than using the tag property with an Index.
0
 
softheartAuthor Commented:
Answer at your questions number 4 and 5.

The error was identified by my client but
I can reproduce it on my development system when I COMPILE IT and use the client's database.

We are using Visual Basic 6.0 SP6 with Dao360.dll (ver. 03.60.2521.8) and MSComctl.ocx (ver. 6.01.9782).
Microsoft Windows 98 2nd edition is not updated to avoid differences with the software on my client's instruments.



The first time I told to my client to delete all record and to retry (to avoid errors on records). In short time the error came out again.
I have also converted the database in Microsoft Access 2000 version but the result does not change.

I have tried to assign the bookmark to the listview key, according to your indications (ID:20118029), but it does not resolve the error.
0
 
aikimarkCommented:
ignore my .Key property suggestion.
============================

6. Try repair/compact of the database

7. Did you create a setup kit for installing the application or just send the compiled executable?

8. My version of DAO is 3.60.8618.0, so yours is a bit back level.


0
 
softheartAuthor Commented:
According to Microsoft (http://support.microsoft.com/kb/239114/) the Dao360.dll ver. 3.60.8618.04.0.8618.0 is for      Windows XP SP2 and Security Bulletin MS04-014.

So I have downloaded and installed the Jet 4.0 Service Pack 8 ("http://download.microsoft.com/download/4/3/9/4393c9ac-e69e-458d-9f6d-2fe191c51469/jet40sp8_9xnt.exe") for computers that are running Windows 98.

This service pack contains the Dao360.dll ver. 3.60.8025.0.
I run the compiled program and the error does not exist!

Thank you.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now