Cannot Add Then Cancel Record In VB6 & Access 2003
I am using VB6 with Access 2003. I must of done something because all of a sudden I cannot add a record and cancel it without causing an error. Here is my code:
strCnn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=myMDB.mdb"
Set adoPrimaryRS = New Recordset
adoPrimaryRS.CursorLocation = adUseServer
strPrimarySQL = "select casename,renldate,product,fundingcode, * from Client " & " order by casename, renldate, product, fundingcode"
adoPrimaryRS.Open strPrimarySQL, cnn1, adOpenStatic, adLockOptimistic
When I want to add a record:
If Not (.BOF Or .EOF Or .RecordCount = 0) Then
mvBookMark = .Bookmark
mvBookMark = 0
I cancel a record by:
If adoPrimaryRS.RecordCount = 0 Then
If mvBookMark > 0 Then
adoPrimaryRS.Bookmark = mvBookMark
If I then go to a previous record I get an "Operation Canceled" error message on the moveprevious statement.
If Not adoPrimaryRS.BOF Then
If adoPrimaryRS.BOF And adoPrimaryRS.RecordCount > 0 Then
'moved off the end so go back
This makes no sense to me because it was working fine 2 weeks ago. I reinstalled MDAC_TYP,EXE. What would cause this to happen. I also repaired the database several times without any success. It seems like a corrupted file someplace but for the life of me I can't figure out which one.
Are there any other errors in the Errors collection of the Connection object?
Microsoft MVP (Visual Basic)
When I do the addnew, in cnn1.error(0) I get "No such interface supported". Then when I get to the CancelUpdate command I get "Operation was canceled"
Last edited by mark1110; 05-07-2007 at 01:37 PM.
You should use the .RollbackTrans after creating a transaction off of the connection object.
Private Sub Form_Load()
On Error GoTo MyError
Dim oCnn As ADODB.Connection
Set oCnn = New ADODB.Connection
'Do insert or update record stuf
Unfortunately rewriting the code is not an option. What would cause something like this to happen.
Here is some more code that first gives me an error "No such interface supported"
Dim oText As TextBox, oCheckbox As CheckBox
Dim oCombo As ComboBox, oList As ListBox, oMaskEDBox As MaskEdBox
Dim ctl As Control
'Bind the text boxes to the data provider
For Each oText In Me.txtFields
Set oText.DataSource = adoPrimaryRS
nDataType = adoPrimaryRS.Fields(oText.DataField).Type
oText.Tag = WhatIsDataType(adoPrimaryRS.Fields(oText.DataField).Type)
txtFields is a control array of textboxes from 0 to 150. I first get the error message on the first textbox. It does populate the text box with the correct information from the access database and it does seem to work when I do a next and previous. But when I add then cancel I get the operation has been canceled error message. .
By kctse1 in forum VB Classic
Last Post: 06-13-2005, 10:59 PM
By me_code2004 in forum Database
Last Post: 06-04-2005, 06:06 AM
By Bob in forum VB Classic
Last Post: 05-09-2001, 09:46 AM
By Jonathan Sullivan in forum VB Classic
Last Post: 04-12-2001, 05:39 AM
By Mak Foka in forum authorevents.kurata
Last Post: 04-18-2000, 08:21 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center