Probs with returning focus to current record

  • Thread starter Thread starter Lee
  • Start date Start date
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
 
-----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
 
Back
Top