New record added to listbox, but won't load rec in form when selec

G

Guest

Hi,

I'm having a data glitch with my Listbox and forms.

I have a main form that contains a Listbox and record information. When the
user selects to create a new record, because of what they need to do, I open
another form for adding. This pop form is closed when the user saves the new
record. I have a Requery in my main form to requery my listbox. The new
record appears in this list box, but when I go to select it, it won't load
it into my form. If I exit the form, re-enter, and select that new record,
it will load it into my form.

Here is the AfterUpdate code for my List64 Box on my main form:

' Find the record that matches the control.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.FindFirst "[CoverID] = " & Str(Nz(Me![List64], 0))
If Not RS.EOF Then Me.Bookmark = RS.Bookmark
Me!Compound.SetFocus

Here is my line in my Form_Activate for my main form:
Me![List64].Requery

What am I doing wrong?
 
M

Marshall Barton

KmhComputer said:
I'm having a data glitch with my Listbox and forms.

I have a main form that contains a Listbox and record information. When the
user selects to create a new record, because of what they need to do, I open
another form for adding. This pop form is closed when the user saves the new
record. I have a Requery in my main form to requery my listbox. The new
record appears in this list box, but when I go to select it, it won't load
it into my form. If I exit the form, re-enter, and select that new record,
it will load it into my form.

Here is the AfterUpdate code for my List64 Box on my main form:

' Find the record that matches the control.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.FindFirst "[CoverID] = " & Str(Nz(Me![List64], 0))
If Not RS.EOF Then Me.Bookmark = RS.Bookmark
Me!Compound.SetFocus

Here is my line in my Form_Activate for my main form:
Me![List64].Requery

What am I doing wrong?


You need to requery the form before it is aware of a new
record from another source.
 
G

Guest

I'm sorry, I'm not sure what you mean. I want to be able to select this new
record from the listbox and have it displayed on the screen without having to
exit my form and re-enter, which is what I have to do now.

The new record is appearing in my listbox after I create it, but when I go
to select that record, the listbox puts puts the first record in my table on
my form instead.
I have to actually close my form and re-enter , select that new record from
my listbox and then it puts it on the form.

What step am I missing? What actually happends when the form is closed and
then re-opened ? I need to simulate that process I guess, without actually
closing my form.


Marshall Barton said:
KmhComputer said:
I'm having a data glitch with my Listbox and forms.

I have a main form that contains a Listbox and record information. When the
user selects to create a new record, because of what they need to do, I open
another form for adding. This pop form is closed when the user saves the new
record. I have a Requery in my main form to requery my listbox. The new
record appears in this list box, but when I go to select it, it won't load
it into my form. If I exit the form, re-enter, and select that new record,
it will load it into my form.

Here is the AfterUpdate code for my List64 Box on my main form:

' Find the record that matches the control.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.FindFirst "[CoverID] = " & Str(Nz(Me![List64], 0))
If Not RS.EOF Then Me.Bookmark = RS.Bookmark
Me!Compound.SetFocus

Here is my line in my Form_Activate for my main form:
Me![List64].Requery

What am I doing wrong?


You need to requery the form before it is aware of a new
record from another source.
 
G

Guest

Hi. I wanted to thank your for your help. I figured it out. I just needed
to add a "form requery" to get the form source to update with the newly added
record.

Thanks for all your help.


Marshall Barton said:
KmhComputer said:
I'm having a data glitch with my Listbox and forms.

I have a main form that contains a Listbox and record information. When the
user selects to create a new record, because of what they need to do, I open
another form for adding. This pop form is closed when the user saves the new
record. I have a Requery in my main form to requery my listbox. The new
record appears in this list box, but when I go to select it, it won't load
it into my form. If I exit the form, re-enter, and select that new record,
it will load it into my form.

Here is the AfterUpdate code for my List64 Box on my main form:

' Find the record that matches the control.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.FindFirst "[CoverID] = " & Str(Nz(Me![List64], 0))
If Not RS.EOF Then Me.Bookmark = RS.Bookmark
Me!Compound.SetFocus

Here is my line in my Form_Activate for my main form:
Me![List64].Requery

What am I doing wrong?


You need to requery the form before it is aware of a new
record from another source.
 
M

Marshall Barton

You're welcome. Good work, glad you worked it out before I
could get back to you.
--
Marsh
MVP [MS Access]

Hi. I wanted to thank your for your help. I figured it out. I just needed
to add a "form requery" to get the form source to update with the newly added
record.

Thanks for all your help.


Marshall Barton said:
KmhComputer said:
I'm having a data glitch with my Listbox and forms.

I have a main form that contains a Listbox and record information. When the
user selects to create a new record, because of what they need to do, I open
another form for adding. This pop form is closed when the user saves the new
record. I have a Requery in my main form to requery my listbox. The new
record appears in this list box, but when I go to select it, it won't load
it into my form. If I exit the form, re-enter, and select that new record,
it will load it into my form.

Here is the AfterUpdate code for my List64 Box on my main form:

' Find the record that matches the control.
Dim RS As Object

Set RS = Me.Recordset.Clone
RS.FindFirst "[CoverID] = " & Str(Nz(Me![List64], 0))
If Not RS.EOF Then Me.Bookmark = RS.Bookmark
Me!Compound.SetFocus

Here is my line in my Form_Activate for my main form:
Me![List64].Requery

What am I doing wrong?


You need to requery the form before it is aware of a new
record from another source.
 

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