Bookmark Listbox

  • Thread starter Thread starter Secret Squirrel
  • Start date Start date
S

Secret Squirrel

I have an unbound listbox on my form that lists all my employees. When I
create a new employee using this form and then click my comman button to save
my record it adds this new employee to the listbox but it does not select
that employee in my listbox even though I'm still on that current record on
my form. I'm using this to bookmark it but it doesn't seem to be working.

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[LastFirst] = '" & Me![EmployeeList] & "'"
Me.Bookmark = rs.Bookmark
 
you're running code in the Save command button's procedure that requeries
the listbox after the record is saved, correct? just add code to set the
value of the listbox control equal to the value of the primary key of the
current record in the form, as

Me!ListboxName = Me!CurrentRecordPrimaryKeyField

hth
 
Hi Tina,

I'm actually just running a Me.recalc in the save command, not a requery.
This way it recalcs the record so I don't requery back to the first record.
When it fires it keeps that new record on my form and adds the new employee
to the list box but it doesn't select that employee in the listbox. Should I
just run what you said and leave the bookmark out?

tina said:
you're running code in the Save command button's procedure that requeries
the listbox after the record is saved, correct? just add code to set the
value of the listbox control equal to the value of the primary key of the
current record in the form, as

Me!ListboxName = Me!CurrentRecordPrimaryKeyField

hth


Secret Squirrel said:
I have an unbound listbox on my form that lists all my employees. When I
create a new employee using this form and then click my comman button to save
my record it adds this new employee to the listbox but it does not select
that employee in my listbox even though I'm still on that current record on
my form. I'm using this to bookmark it but it doesn't seem to be working.

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[LastFirst] = '" & Me![EmployeeList] & "'"
Me.Bookmark = rs.Bookmark
 
Yep, that worked. Thanks for your help Tina!
You can disregard my other response.

SS

tina said:
you're running code in the Save command button's procedure that requeries
the listbox after the record is saved, correct? just add code to set the
value of the listbox control equal to the value of the primary key of the
current record in the form, as

Me!ListboxName = Me!CurrentRecordPrimaryKeyField

hth


Secret Squirrel said:
I have an unbound listbox on my form that lists all my employees. When I
create a new employee using this form and then click my comman button to save
my record it adds this new employee to the listbox but it does not select
that employee in my listbox even though I'm still on that current record on
my form. I'm using this to bookmark it but it doesn't seem to be working.

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[LastFirst] = '" & Me![EmployeeList] & "'"
Me.Bookmark = rs.Bookmark
 
you're welcome, hon. btw, let me just mention that i assumed you were
running code from the cmd button, after the save command, to requery *the
listbox*, not the entire form.


Secret Squirrel said:
Yep, that worked. Thanks for your help Tina!
You can disregard my other response.

SS

tina said:
you're running code in the Save command button's procedure that requeries
the listbox after the record is saved, correct? just add code to set the
value of the listbox control equal to the value of the primary key of the
current record in the form, as

Me!ListboxName = Me!CurrentRecordPrimaryKeyField

hth


Secret Squirrel said:
I have an unbound listbox on my form that lists all my employees. When I
create a new employee using this form and then click my comman button
to
save
my record it adds this new employee to the listbox but it does not select
that employee in my listbox even though I'm still on that current
record
on
my form. I'm using this to bookmark it but it doesn't seem to be working.

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[LastFirst] = '" & Me![EmployeeList] & "'"
Me.Bookmark = rs.Bookmark
 
Back
Top