Listbox - subForm

J

John Smith

Hi!

I'm always getting an error message when I trie to refresh a lstBox on a
Form from a subform...

Here's my code:

Private Sub Form_AfterUpdate()
Dim str As String

str = "SELECT Bloc_Temp_Expedition.NoShip, " & _
"Format(Sum(Bloc_Temp_Expedition.Volume),'0.00') AS SommeDeVolume, " &
_
"Format(Sum(Bloc_Temp_Expedition.Poids),'0.00') AS SommeDePoids " & _
"From Bloc_Temp_Expedition " & _
"GROUP BY Bloc_Temp_Expedition.NoShip " & _
"HAVING Bloc_Temp_Expedition.NoShip<>0"

Forms!Expedition_DemandeBloc_Liste!LstSommaire.Refresh

End Sub

Any idea what's the problem?
 
A

Albert D. Kallal

The "trick" to help you remember what is going on here is that a sub-form is
NOT really a form, but just a regular control that POINTS to a the sub-form.
(you can place the same sub-form on a form 5 times.).

So, go get at the actual "form" of the control..you use the ".form"
property.

So, try:

me!SubFormContorl.Form!LstSommaire.Refresh

So,what is the name of the sub-form control on your form? (this name can be
difference then what the actual sub-form that is referenced by this
control).

Also, that whole bunch of sol you shove in to str....you never do anything
with it? Did you want to make the listbox source that sql?

If yes, then go:

me!SubFormContorl.Form!LstSommaire.RowSource = str

You don't need a requery..as setting the recordsouce does this for you....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top