Solved Record do not show up when requery but their saved (1 Viewer)

jgcns

New member
Local time
Today, 09:15
Joined
Dec 31, 2020
Messages
12
Good Evening all,

I'm facing a strange situation... I have a Form that opens and allow user to select some products. Then when they're finished, they close it and another form shows the request header and the selection. The problem is that the list of chosen items on this second form is always, one item less than the suppose.
If I requery again or close and open the form it shows all the selected items...

My code:
I have some trigger on the first form closure that requery the second one...

Private Sub Form_Close()

If Me![FormRequisitionBody].Form.Dirty Then

Forms.RequisitionBaseReq.FormRequisitionBodyviewonly.Requery
Forms.RequisitionBaseReq.FormRequisitionBodyviewonly.Form.Dirty = True

End If

End Sub

What am i doing wrong?

Ps.: I'm a newbie on access, but i'm focus on improovement.

Thank you,

Best regards,

João Santos
1609620662318.png

1609620694187.png
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:15
Joined
Sep 21, 2011
Messages
14,037
Firstly I'd see if that code even runs?
Secondly, why not just open the second form on closure of the first form?
 

jgcns

New member
Local time
Today, 09:15
Joined
Dec 31, 2020
Messages
12
Good evening,

Form description:

One form with requisition order header and Selected products ( general view)(second form) then you click to choose items and opens up another form with a seach engine that allow user to choose the items. This Search engine has code "on close" part (first one), ordering to requery General View.
And it actually does. Some of the items shows up on Gen View, but never the very last item. Only if i requery again.. ( the Gen view it is allways open)

do you have any Idea why this is happening?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:15
Joined
May 7, 2009
Messages
19,169
your Don't test if it is Dirty or Not Dirty, just requery the form regardless.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:15
Joined
Feb 19, 2002
Messages
42,970
You seem to be using requery to save your record - bad practice. Requery does exactly what it says but as a SIDE EFFECT, it saves the current record. If you want to save a record save it. PERIOD. ALWAYS save the current record before opening a second form from it or the changes you made will not be available in the pop up.

As a matter of understanding, when you open a form, Access loads the recordset into memory. So when form a opens form b and form b adds a record to the recordset being viewed by form a, you won't see it because the new record is on disk but it is not in memory. That is why requerying form a shows the new record and THIS is the purpose of requery. Run the forms query again to pick up changes to the recordset.
 

Users who are viewing this thread

Top Bottom