refresh sub form

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

Guest

Is there a way to refresh only the sub form and not the main?
I tried forms![subfrmname].refresh and it says it cannot find subfrmname?
 
Cynthia said:
Is there a way to refresh only the sub form and not the main?
I tried forms![subfrmname].refresh and it says it cannot find subfrmname?

subfrmname must be the name of the subform control on your form which is
acting as the container for your form. So if the control is called
SubformCtl and the form it hosts is called Form1 then the syntax for code in
the form's module would be:

Me!SubformCtl!Form1.Form.Refresh
 
The name of the form that is hosted in the subform control, is not
required. And, she proably really means to Requery - not Refresh. So:

Me![SubformCtl].Form.Requery

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
When I use the requery, all I get is a blank screen until I leave the record
adn come back. The name and source object are frmWireTerm. The from it is
using is also called frmWireTerm. Do I need to change the name of the
control so it does not match the form name? My Here is my code

strQry = "Delete from EleWireTerm Where EleWireTerm.CircId = " & CircID & ""
DoCmd.RunSQL (strQry)
strQry = "INSERT INTO EleWireTerm (CircID, CableID, WireID, Wire) " & _
"Select '" & CircID & "', '" & cableID & "', [EleWires].wireid,
[EleWires].wire " & _
"From [EleWires] Where [eleWires].CableID = " & cableID & ""
DoCmd.RunSQL (strQry)
Me!frmWireTerm.Requery
 
Your Requery statement does not match what I suggested - you omitted
the "dot form" part. But now that I think of it, I'm not sure if this
would actually matter, or not!

There's nothing /theoretically/ wrong with naming the subform control
the same as the form within it - but this is a recipe for confusion
when you are reading the code afterwards. I suggest that you name the
subform control "sfWireTerm", or somesuch. Then try this for the
Requery:

me![sfWireTerm].form.requery

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
Me![sfWireTerm].Form.Requery
When I put this line in my subform becomes blank. No records show.
If I put in Me.refresh my subform will show the new items?
 
If Requery-ing the subform makes it go blank, it suggests that you are
deleting all the records that the subform would have displayed.

Inserting the following statement:
debug.print strQuery

immediately before each of the two statements:
DoCmd.RunSQL (strQry)

Then run the code again, type ctrl-g to go to the debug window, copy
the output of the two debug.print commands, and past that back here. I
think you will find that the INSERT statement is not inserting what you
think it is.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
Below are the two queries. Why would it give me the data if I change records
and come back or if I do an me.refresh? When I use the combo box I am
changing the
cableid that the form is linked to.

Delete from EleWireTerm Where EleWireTerm.CircId = 1
INSERT INTO EleWireTerm (CircID, CableID, WTNum, WireID) Select '1', '2',
'1', [EleWires].wireid From [EleWires] Where [eleWires].CableID = 2
 
Back
Top