close subforms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to close a subform within a mainform so I can extract datat to
SAS and send it back to repopulate the table with new data. I need the syntax
to close the subform. Here is what I am using to close teh main form

tname = [Form_main].RecordSource
'MsgBox [Form_main].RecordSource
[Form_main].RecordSource = ""
DoCmd.Close acTable, tname
'MsgBox "Table closed"

and this for the subform

t1name = [subform_sub].RecordSource
'MsgBox [subform_sub].RecordSource
[subform_sub].RecordSource = ""
DoCmd.Close acTable, t1name
'MsgBox "Table closed"

The object "subform_sub" is not recognized. I need to close all forms to
export back to Access from SAS. I have a mainform with several subforms
reading 3 tables and one query. I need to close all to "reload the data".
Thanks!!
 
There is no need to close the forms. I don't know what you mean by
"reload". If you want to requery to get the latest updates from the SAP
tables, then do that.

Me.Requery

You only need to requery the main form. Doing that will also requery the
subforms as long as the master/child links are properly set.

You can't "close" subforms. You can only close the mainform. You can
"unbind" a form from its RecordSource by setting the RecordSource to Null.
This "closes" the table/tables from the form's point of view. However,
doing this in a mainform when there are subforms may cause a problem unless
you do the same to them first.

Me.Subform1.RecordSource = Null
Me.Subform2.RecordSource = Null
Me.RecordSource = Null
 
Back
Top