Probs with returning focus to current record

L

Lee

Hi everyone,
I'm sure this is me being dim but I can't see why the
following doesn't work. All I want is for the focus to
return to the current record (within an unbound listbox)
once an update query has been run. The form's record
source is different to the listbox by the way.

Dim intCentre As Integer

intCentre = txtCentreNo (this textbox holds the same
value as the bound column of the listbox - a five digit
number)

DoCmd.Echo False
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_UpdateAllocation"
DoCmd.SetWarnings True
DoCmd.SelectObject acForm, "frm_Allocations"
DoCmd.Requery
DoCmd.GoToControl "lstCentres"
DoCmd.Requery "lstCentres"
DoCmd.FindRecord intCentre, acEntire, False,
acSearchAll, True, acCurrent, True
DoCmd.Echo True

Should I be using a recordset bookmark instead? If so,
how do I do this when the listbox's record source is
different to that of the form? I'm a newbie (no,
really!!?) so would appreciate a more detailed reply in
words of one syllable.
Thanks in advance

Lee
 
J

Jonathan Parminter

-----Original Message-----
Hi everyone,
I'm sure this is me being dim but I can't see why the
following doesn't work. All I want is for the focus to
return to the current record (within an unbound listbox)
once an update query has been run. The form's record
source is different to the listbox by the way.

Dim intCentre As Integer

intCentre = txtCentreNo (this textbox holds the same
value as the bound column of the listbox - a five digit
number)

DoCmd.Echo False
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_UpdateAllocation"
DoCmd.SetWarnings True
DoCmd.SelectObject acForm, "frm_Allocations"
DoCmd.Requery
DoCmd.GoToControl "lstCentres"
DoCmd.Requery "lstCentres"
DoCmd.FindRecord intCentre, acEntire, False,
acSearchAll, True, acCurrent, True
DoCmd.Echo True

Should I be using a recordset bookmark instead? If so,
how do I do this when the listbox's record source is
different to that of the form? I'm a newbie (no,
really!!?) so would appreciate a more detailed reply in
words of one syllable.
Thanks in advance

Lee
.
Hi Lee,
either use the goto record or use the recordset bookmark

me.recordsetclone.bookmark.findfirst "CentreID=" &
intCentre
me.bookmark=me.recordsetclone.bookmark

Luck
Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top