[AccessD] When to Requery?

Dan Waters dwaters at usinternet.com
Wed Dec 5 20:35:25 CST 2007


Hi Arthur,

On the Click event of the Save button after the new record is inserted try
this:

Forms("Transactions_fsub").OrderByOn = True
Forms("Transactions_fsub").OrderBy = "TransactionDate DESC"

I'm pretty sure that resorting will force a requery.

Hope this Helps!
Dan

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller
Sent: Wednesday, December 05, 2007 8:00 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] When to Requery?

I have a form with a subform (you've heard this one, I bet).

The subform is R/O and there's a button to add a new Item. This pops up a
dialog form that accepts the new data. The form has a button to Save, which
writes the record and then closes the form. I want to requery the subform to
reflect the newly added item at the top of the list.

The subform is sorted by TransactionID DESC, but my various attempts to
requery the subform suggest that I'm doing it in the wrong event. Here is
the scenario in more literal terms:

Main form: Riders_frm
Sub form: Transactions_fsub, containing a button that invokes "New
Transaction", which opens Transactions_New_frm.
User clicks Save on said dialog. Dialog closes, returning the user to the
Main form.

At this point, I wish the sub-form (Transactions_fsub) to refresh or requery
and display the newly-added record at the top of the grid, NOT at the bottom
(which it is currently doing). Yes, the user can re-sort the data but that's
not what I want. I want the Transactions to be sorted (either TransactonID
DESC or TransactionDate DESC -- both will work), but I can't seem to
automate it. Keystrokes are required and that's what I want to get around.

Any suggestions?

TIA,
Arthur
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list