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

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?



Sat, 08 Nov 2008 03:48:02 GMT  
 New record added to listbox, but won't load rec in form when selec

Quote:

>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.

--
Marsh
MVP [MS Access]



Sat, 08 Nov 2008 05:05:58 GMT  
 New record added to listbox, but won't load rec in form when selec
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.

Quote:


> >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.

> --
> Marsh
> MVP [MS Access]



Sat, 08 Nov 2008 05:20:02 GMT  
 New record added to listbox, but won't load rec in form when selec
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.

Quote:


> >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.

> --
> Marsh
> MVP [MS Access]



Sat, 08 Nov 2008 06:33:02 GMT  
 New record added to listbox, but won't load rec in form when selec
You're welcome.  Good work, glad you worked it out before I
could get back to you.
--
Marsh
MVP [MS Access]
Quote:

>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.



>> >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.

>> --
>> Marsh
>> MVP [MS Access]



Sat, 08 Nov 2008 08:04:32 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Adding a new record to a form whose record source is a listbox

2. Move to newrecord adds rec to db, but cant move to new rec

3. New Rec with Data Based on Previous Rec's Data

4. Add new Rec's to a Sub frm when Allow Additions = False

5. add-in manager won't load add-ins

6. word VBA won't let me add a new record to an access table

7. Problem with adding new rec with form containing a subform

8. Selecting new record in listbox after record is added

9. Form Won't Allow New Records

10. popup form won't create new record!


 
Powered by phpBB® Forum Software © phpBB Group