Re: ERROR- Update' or CancelUpdate without AddNew or Edit
From: PavelKo (PavelKo_at_NOkonecnySPAM.cz)
Date: 09/13/04
- Next message: david epsom dot com dot au: "Re: Error Message different in MDB and MDE"
- Previous message: Dan Artuso: "Re: TreeView: Sorted Method dont work"
- In reply to: Don Starnes: "Re: ERROR- Update' or CancelUpdate without AddNew or Edit"
- Next in thread: Don Starnes: "Re: ERROR- Update' or CancelUpdate without AddNew or Edit"
- Reply: Don Starnes: "Re: ERROR- Update' or CancelUpdate without AddNew or Edit"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 14 Sep 2004 01:49:38 +0200
Hi,
selecting of row in listbox depends on two listbox's properties: MultiSelect
and ColumnHeads.
For MultiSelect set to None:
'check, if there are any rows to choose from
lngCount = Me.groups.ListCount
If Me.groups.ColumnHeads Then 'column heads costs one row...
lngCount = lngCount - 1
End If
If lngCount <= 0 Then
MsgBox "There is no item to select!", vbExclamation
Exit Sub '..or whatever you want
End If
' now select first row below heads if any
' If uses ColumnHeads, the first row is the heads
If Me.groups.ColumnHeads Then
l = 1
Else
l = 0
End If
Me.groups.Value = (Me.groups.Column(Me.groups.BoundColumn - 1, l) + 0)
For MultiSelect set to Simple/Extended:
If Me.groups.ColumnHeads Then ' If uses ColumnHeads, the first row is
the heads
l = 1
Else
l = 0
End If
Me.groups.Selected(l) = True
Pavel K.
"Don Starnes" <DonStarnes@discussions.microsoft.com> píše v diskusním
příspěvku news:590A2516-6308-4E8F-934E-28EE0CEFAC78@microsoft.com...
> Ken--
>
> Thanks for your help!
>
> Repairing, deleting and reimporting didn't help. Through these measures
and
> further testing (adding the code for the [event propceedure] back one line
at
> a time), I have found that the error only occurs when the
>
> Me.groups.Selected(0) = True
>
> statment is included (yes, "groups" is the name of the control; I'm glad
> that you knew what I meant ;--} ).
>
> I'm trying, of course, to select the first item of the listbox after the
> list is updated (I would then uxe the selected item to update other
> controls). I see no reason why this line causes this error.
>
> Is there something wrong with this statement?
>
> Don
>
> "Ken Snell [MVP]" wrote:
>
> > This code, as you've concluded, should not be a source of the error.
It's
> > possible that the compiled code has become confused in the form's
module. Or
> > that the form has become corrupted.
> >
> > When you deleted this procedure, did you close the form (saving the
changes,
> > of course), and then do a compact/repair on the database? If not, try
that
> > (keep copy of the procedure that you delete). Then put the procedure
back
> > into the form's module (tie it to the OnCurrent property via [Event
> > Procedure], of course). See if that eliminates the problem.
> >
> > If it doesn't you might try importing the form into a new database and
> > delete it from the current database. Compact/repair the current
database.
> > Then reimport the form from the new database back into the original
> > database.
> >
> > If these don't work, post back and we'll see what other options we might
> > try.
> > --
> >
> > Ken Snell
> > <MS ACCESS MVP>
> >
> > "Don Starnes" <DonStarnes@discussions.microsoft.com> wrote in message
> > news:D7054469-968A-4740-A184-FFFFF5D85FD8@microsoft.com...
> > > Ken--
> > >
> > > I managed to delete the proceedure that I had been working on when
this
> > > happened and made the error go away. But when I add the proceedure
back
> > in, I
> > > get the error again after I navigate to the next record. The offending
> > > proceedure is:
> > >
> > > Private Sub Form_Current()
> > > ' when the form goes to a new record:
> > > ' requery the groups control
> > > Me.groups.Requery
> > > ' select the first item in the groups control
> > > Me.groups.Selected(0) = True
> > > End Sub
> > >
> > > "controls" is a listbox whose recordset is a query as a SQL statement.
The
> > > query has as a criteria a field on the form that is bound to a field
in
> > the
> > > form's current table.
> > >
> > > How is this proceedure giving me that error? What is wrong with this
> > > proceedure?
> > >
> > > Thanks!
> > > "Ken Snell [MVP]" wrote:
> > >
> > > > Somewhere in code that is running is an Update statement for a
recordset
> > > > that doesn't have an AddNew or an Edit statement preceding it in the
> > code.
> > > > Likely inadvertent commenting out of some code lines, or accidental
> > deletion
> > > > of some code lines.
> > > >
> > > > Do a "Find" for the text string ".Update" in your modules and see if
you
> > can
> > > > find the offending code snippet.
> > > >
> > > > --
> > > >
> > > > Ken Snell
> > > > <MS ACCESS MVP>
> > > >
> > > >
> > > >
> > > > "Don Starnes" <DonStarnes@discussions.microsoft.com> wrote in
message
> > > > news:F09648E0-D1C6-4FBD-A049-CD095452586B@microsoft.com...
> > > > > I was editing a proceedure for a form and I started getting this
error
> > > > when I
> > > > > attempt to navigate on my form in any way.
> > > > >
> > > > > The proceedure (current) simply requeried a listbox and then set
it's
> > > > > selected property. When I commented out the lines in the
proceedure or
> > > > even
> > > > > deleted the proceedure, the error wouldn't go away.
> > > > >
> > > > > What causes this error?
> > > >
> > > >
> > > >
> >
> >
> >
- Next message: david epsom dot com dot au: "Re: Error Message different in MDB and MDE"
- Previous message: Dan Artuso: "Re: TreeView: Sorted Method dont work"
- In reply to: Don Starnes: "Re: ERROR- Update' or CancelUpdate without AddNew or Edit"
- Next in thread: Don Starnes: "Re: ERROR- Update' or CancelUpdate without AddNew or Edit"
- Reply: Don Starnes: "Re: ERROR- Update' or CancelUpdate without AddNew or Edit"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|