Weird Error Message: Update or CancelUpdate without AddNew or Edit (1 Viewer)

flofi

Registered User.
Local time
Today, 16:23
Joined
Sep 20, 2004
Messages
15
Hi

Starting form a form on a empty NewRecord I'm looking for a specific record on a search form. When i chose another record I update the recordSource of the initial form and requery the form. After that, if I want to move from one field to another I get this error message:

"Update or CancelUpdate without AddNew or Edit"

But I've never interferred with the recordset. I have just one beforeUpdate event on the form's controls. But it didn't help to remove this procedure. None of the controls has a validation rule.

What could cause this error. Thanks for your help.

flofi
 

Mile-O

Back once again...
Local time
Today, 15:23
Joined
Dec 10, 2002
Messages
11,316
Post your code...it helps.

You probably have something like:

Code:
With rs
     .Fields("Fieldname") = newValue
     .Update
End With

when you need:

Code:
With rs
     .Edit ' or AddNew if adding a record
     .Fields("Fieldname") = newValue
     .Update
End With
 

flofi

Registered User.
Local time
Today, 16:23
Joined
Sep 20, 2004
Messages
15
I don't have code

Thanks for your answer SJ McAbney. The problem is that I don't have code manipluating recordsets. But i found the code line causing the situation. (The error only occurs after I try to exit the active control on the form. I still don't understant why this causes problems.

Code line causing the situation:

Forms.frmPsdEntry.lstAllTest.Selected(lngPsdTestPos - 1) = True

lstAllTest is a list box on the form wher I show the available records on a joined table.

Thanks for help

flofi
 

Mile-O

Back once again...
Local time
Today, 15:23
Joined
Dec 10, 2002
Messages
11,316
Use the AfterUpdate event and not an OnExit event. The OnExit event occurs before the field has been updated.
 

flofi

Registered User.
Local time
Today, 16:23
Joined
Sep 20, 2004
Messages
15
There is no code associated with the unbound textField. The error must occur in the code before anything can be done on the form.

The code does the following:
1. create the query having one record as result
2. define the query as the recordSource of the form
3. requery the form
4. override data mode properties of the form
- allowEdits = true
- allowAdditions = false
- allowDeletions = false
- dataEntry = false
5. define the value list of the list box
6. this code:
If lngRowCount > 0 Then
Forms.frmPsdEntry.lstAllTest.Enabled = True
Forms.frmPsdEntry.lstAllTest.Selected(lngPsdTestPos - 1) = True
Call setPsdTestQry(Forms.frmPsdEntry.lstAllTest.Column(1))
Forms.frmPsdEntry!sfrmPsdTest.Form.RecordSource = "qryPsdTest"
Forms.frmPsdEntry!sfrmPsdTest.Form.Requery
Forms.frmPsdEntry.pgeTest.Visible = True
Call Forms.frmPsdEntry.pgeTest.SetFocus
If blnGlbReadOnly Then
Forms.frmPsdEntry.sfrmPsdTest.Form.psdTestNum.value = strGlbPsdTestNum(0, lngPsdTestPos - 1)
Forms.frmPsdEntry.sfrmPsdTest.Form.psdMatState.value = strGlbPsdTestNum(1, lngPsdTestPos - 1)
End If
Forms.frmPsdEntry.pgeMeasure.Visible = True
Else
Forms.frmPsdEntry.lstAllTest.Enabled = False
'hide all subforms
Call setPsdTestQry(0)
Forms.frmPsdEntry!sfrmPsdTest.Form.RecordSource = "qryPsdTest"
Forms.frmPsdEntry!sfrmPsdTest.Form.Requery
If Forms.frmPsdEntry.projectShort.Enabled Then
Forms.frmPsdEntry.projectShort.SetFocus
Else
Forms.frmPsdEntry.plant.SetFocus
End If
Forms.frmPsdEntry.pgeTest.Visible = False
Forms.frmPsdEntry.pgeMeasure.Visible = False
End If

?!?!

Thanks

flofi
 

Mile-O

Back once again...
Local time
Today, 15:23
Joined
Dec 10, 2002
Messages
11,316
Sorry, when I said OnExit, I meant BeforeUpdate - same applies. You can't assign values in this event - use the AfterUpdate event.
 

flofi

Registered User.
Local time
Today, 16:23
Joined
Sep 20, 2004
Messages
15
I don't really understand what you mean. My textField is called projectShort and is bound (I said the opposite above) to the field called the same in a table. In the properties of this textField there is absolutely no Event procedure associated. I don't use Before/AfterUpdate, OnExit or whatever...

I addition: When i remove the codeline stated above the error doesn't occur, but then my list box entry isn't selected. And I want it selected...

What can I do?
 

flofi

Registered User.
Local time
Today, 16:23
Joined
Sep 20, 2004
Messages
15
Thanks a lot SJ McAbney for beeing so patient with me. But this BeforeUpdate event didn't change anything when I removed it. So I forgot about it.

What finally worked was to put the selection of the list row some lines more downwards. I still don't know why this changes so much, but I have my programm working with this.

Thanks again

flofi
 

Users who are viewing this thread

Top Bottom