Refresh subform

  • Thread starter Βάππας Κωνσταντίνος
  • Start date
Î

Βάππας Κωνσταντίνος

I have a main form which is unbound and a subform which is bound. I make a
selection from a list box of the main form and i see records in subform. In
case that there aren't records, it runs an append query creating them with
null values in some of the fields which user can change later.
The problem is that when query creates records user must make the selection
again to see the records in subform. How can i refresh the subform
automatically?
I run command refresh through a macro but it says that the command or action
refresh isn't available.
 
A

Allen Browne

Could you add the record to the RecordsetClone of the subformin instead of
appending directly to the table:

With Me.[NameOfYourSubformControl].Form.RecordsetClone
.AddNew
![NameOfSomeFieldHere] = Me.[ListBoxValueToMatch]
.Update
End With
 
D

Dirk Goldgar

?????? ???????????? said:
I have a main form which is unbound and a subform which is bound. I
make a selection from a list box of the main form and i see records
in subform. In case that there aren't records, it runs an append
query creating them with null values in some of the fields which user
can change later.
The problem is that when query creates records user must make the
selection again to see the records in subform. How can i refresh the
subform automatically?
I run command refresh through a macro but it says that the command or
action refresh isn't available.

As an alternative to Allen Browne's suggestion -- which should work --
you could simply requery the subform after adding the records. It's not
clear from your description whether the code that runs the append query
is executing on the main form or the subform. My guess is that the code
is on the main form, in which case you would just need to add a
statement of the form

Me!NameOfSubform.Requery

where "NameOfSubform" is the name of the subform control on the main
form, which may or may not be the same as the name of the form object
that the subform control displays.

If the code runs on the subform itself, on the other hand, the statement
to execute would be

Me.Requery
 
Top