Can't Requery Listbox

  • Thread starter Thread starter JamesJ
  • Start date Start date
J

JamesJ

This is getting annoying.
I have a form with a listbox (lstDvd) both are based on the same select
statement.
(tblDvd).tblDvd has 4 fields: DvdMovieID, DvdMovieTitle, DvdMovieType and
DvdSynposis.
The only visible column in the listbox is DvdMovieTitle. On the form I have
placed all 3 fields. When I select a title in the listbox I'm using the
following
code so the form and the lisbox are on the same record:

Private Sub lstDvd_AfterUpdate()

Me.RecordsetClone.FindFirst ("DvdMovieID = " & Me!lstDvd)
Me.Bookmark = Me.RecordsetClone.Bookmark

End Sub

Here's the problem. When I click the New Record button the form goes
to the new record and DvdMovieTitle has the focus. When I move to
another row in the list box I get the following error message:

'2001' You canceled the previous operation

I'm using the following in the AfterUpdate of the form:

Private Sub Form_AfterUpdate()

Me.Requery
Me.lstDvd.Requery

End Sub

The record gets saved but I must close and then reopen the see it.

I'm using the same code with different objects in another form but
I'm getting a different error message when I select another row in it's
listbox:

'3021' No current record. The listbox goes blank until I click End.
In both cases the debugger goes to:

Me.Bookmark = Me.RecordsetClone.Bookmark

No fields are required either at the table or form level.

Any help will be extremely appreciated.
James
 
Hi James

First of all, you do not need Me.Requery in your Form_AfterUpdate procedure.

Requerying the entire form will fire a whole bunch of other events and it's
possible that one of them is causing the problem.

Also (just to be sure!) you do realise that the listbox *must* be unbound
don't you?

Post back to say how you get on and if deleting the requery does not work
we'll dig a bit deeper :-)
 
Removing the Me.Requery worked. I was a bit preoccupied with removing
the requery for the listbox 'cause I thought that was the culprit.
Works ok now in both forms.

Thanks much,
James

Graham Mandeno said:
Hi James

First of all, you do not need Me.Requery in your Form_AfterUpdate
procedure.

Requerying the entire form will fire a whole bunch of other events and
it's possible that one of them is causing the problem.

Also (just to be sure!) you do realise that the listbox *must* be unbound
don't you?

Post back to say how you get on and if deleting the requery does not work
we'll dig a bit deeper :-)
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

JamesJ said:
This is getting annoying.
I have a form with a listbox (lstDvd) both are based on the same select
statement.
(tblDvd).tblDvd has 4 fields: DvdMovieID, DvdMovieTitle, DvdMovieType and
DvdSynposis.
The only visible column in the listbox is DvdMovieTitle. On the form I
have
placed all 3 fields. When I select a title in the listbox I'm using the
following
code so the form and the lisbox are on the same record:

Private Sub lstDvd_AfterUpdate()

Me.RecordsetClone.FindFirst ("DvdMovieID = " & Me!lstDvd)
Me.Bookmark = Me.RecordsetClone.Bookmark

End Sub

Here's the problem. When I click the New Record button the form goes
to the new record and DvdMovieTitle has the focus. When I move to
another row in the list box I get the following error message:

'2001' You canceled the previous operation

I'm using the following in the AfterUpdate of the form:

Private Sub Form_AfterUpdate()

Me.Requery
Me.lstDvd.Requery

End Sub

The record gets saved but I must close and then reopen the see it.

I'm using the same code with different objects in another form but
I'm getting a different error message when I select another row in it's
listbox:

'3021' No current record. The listbox goes blank until I click End.
In both cases the debugger goes to:

Me.Bookmark = Me.RecordsetClone.Bookmark

No fields are required either at the table or form level.

Any help will be extremely appreciated.
James
 
Back
Top