Subform refreshing

  • Thread starter Thread starter Sheldon Mopes
  • Start date Start date
S

Sheldon Mopes

I can't get this to wotk the way I want it. here goes:

I have a form which contains a subform based on a query of TableX. The
subform order is a time field in TableX. By double-clicking a record
in the subform, another form is open, which can edit a record (of
TableX, of course.) Now, if I edit the time field in the record, I
want the subform to redisplay with the records in the new time order
when I clse the edit form, but I can't get it to work. Any help would
be greatly appreciated. Thank you.
 
If you are trying to create a join between tables using a Date/Time field,
abandon the idea and redesign the tables.

Internally, Access uses a floating point number to store date/time values.
The date is stored in the integer part, and the time of day in the
fractional part. The time is therefore a floating point value, and subject
to all the problems computer have in trying to match floating point values.

Although a child record will inherit the original value correctly, and you
can use cascading updates to cascade any change from the primary table to
the related table, attempting to match values is going to cause you far more
heartache than you want. Even values that appear to be the same will not
match.

A simple workaround is to use an AutoNumber in the main table and a Number
field in the related table. You can still have the date/time field--even
marked required and with a unique index on the field if you wish, but you
avoid all the floating point problems.
 
Thank you for your help, but I just want to know how to refresh the
subform. It is not a join, just an ordering of the subform based on a
time. It is not compared to other time fields.
 
Sorry: you are not joining to the main form on a date/time field; you just
want to requery the subform.

If the focus is in the subform, just pressing Shift+F9 should do that.

To do it programmatically:
Me.Requery
or if the code is in the main form:
Me.[Sub1].Form.Requery
where Sub1 represents the name of your subform control.

Note that requerying reloads the subform, so the first record will become
the active one.
 
No, the problem is that I need the edit form (not the main form) which
is opened by the DblClick Event on the subform to refresh the subform
when the edit form closes. That is what I can't figure out. I already
have a requery command button on the main form, I would like to have
the On Exit Event of the edit form do the requery/refresh. Thanks.
 
The idea is to Requery whatever form it is, and however you refer to it.

That might be:
Forms![MyMain]![Sub1].Form.Requery
the the AfterUpdate or Close event of the edit form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Sheldon Mopes said:
No, the problem is that I need the edit form (not the main form) which
is opened by the DblClick Event on the subform to refresh the subform
when the edit form closes. That is what I can't figure out. I already
have a requery command button on the main form, I would like to have
the On Exit Event of the edit form do the requery/refresh. Thanks.


Sorry: you are not joining to the main form on a date/time field; you just
want to requery the subform.

If the focus is in the subform, just pressing Shift+F9 should do that.

To do it programmatically:
Me.Requery
or if the code is in the main form:
Me.[Sub1].Form.Requery
where Sub1 represents the name of your subform control.

Note that requerying reloads the subform, so the first record will become
the active one.
 
Back
Top