Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Wrox Announcements and Feedback > All Other Wrox Books
All Other Wrox Books Do you have a question about a Wrox book that isn't listed anywhere on p2p.wrox.com or where the forum is locked? Here's a forum to post questions about any other Wrox book so that other readers or one of the authors can help you with your questions. IF YOU ARE LOOKING FOR CODE DO NOT ASK "Where can I find the code for this book?" That question is answered here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the All Other Wrox Books section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 16th, 2003, 09:20 AM
Registered User
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Beginning Visual Basic 6 Database Programming

Below is a chunk of code that I'm running from chapter 6.

Private Sub cmdButton_Click(Index As Integer)
  Static vMyBookMark As Variant
  Select Case Index 'what is the value of the key pressed?
    Case cmdMoveFirst
    Case cmdMovePrevious
    Case cmdMoveNext
    Case cmdMoveLast
    Case cmdAddNew
    Case cmdEdit
      With Data1.Recordset
        If (.EditMode = dbEditNone) Then
          vMyBookMark = .Bookmark
          Call updateButtons
          lblRecordCount = "Editing"
        End If
      End With
    Case cmdSave
    Case cmdDelete
    Case cmdUndo
    Case cmdFind
    Case cmdDone
  End Select
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  Dim iMessage As Integer

  If (Data1.Recordset.EditMode <> dbEditNone) Then
    iMessage = MsgBox("You must complete editing the _
     current record", vbInformation, App.EXEName)
    Cancel = True
  End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
  Set frmPublishers = Nothing
End Sub

The code is suppose to prevent the user from closing down the form or window when they are in the middle of editing a record. The problem is the expression "Data1.Recordset.EditMode <> dbEditNone" in the if statement never becomes true like the book says it should. The Data1.Recordset.EditMode = vbEditInProgress after the Case cmdEdit runs the .Edit method. But as soon as the code reaches Private Sub Form_QueryUnload the Data1.Recordset.EditMode changes to vbEditNone!

Thanks in advance,

Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginning Visual Basic 6 database zach007 Wrox Book Feedback 1 January 24th, 2006 11:42 PM
Beginning Visual basic 6.0 DataBase visualizebasic Wrox Book Feedback 0 June 14th, 2005 03:41 AM
Chapter6 - Beginning Visual Basic 6 Database Prog. jdeaver VB Databases Basics 1 September 29th, 2004 11:01 AM
beginning visual basic 6 database programming gskarns1 VB Databases Basics 1 September 29th, 2004 10:46 AM
Beginning Visual Basic 6 Database Programming lizardnotebk All Other Wrox Books 1 December 16th, 2003 01:45 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.