Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form (On Return) -Run A SUB

Status
Not open for further replies.

kennedymr2

Programmer
May 23, 2001
594
AU
I have a form say named form1 loaded.

Form1 has a set of totals which i need to keep current.
On hitting a command button i go to form2 (form2.Show), this form writes data to a table., totals of which which i need to display on form1.
On return to the Form1 i need to automatically run a (sub called TotalAll)
which adds data from various tables.

I have tried form1.gotfocus with no results.!

??How do i get this sub TotalAll to run on form1 when i exit the form2.

Appreciate any help.




 
Can't you call the sub from form2?

or unload form1 within form2 then re-load form1 when you exit form 2?
 
Thanks for you quick reply (Wzup)
I have tried on exit from form2

form1.totalall
but it comes up with an error (method or data member not found)

i am unable to unload the form1 and reload, as form1 has all sorts of current data on it, which i would lose if i unloaded the form.

regards kennedymr2


 
Look at the place where you declare the TotalAll subroutine. Does it look like....

Private Sub TotalAll
[green]' lines of code [/green]
End Sub

try changing it to....

Code:
[red]Public[/red] Sub TotalAll
[green]' lines of code [/green]
End Sub

By making it a public sub, you should be able to call it from anywhere within your app with this line...

Call Form1.TotalAll



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
gmmastros (Programmer)

Yes, on your advice, i have tried making it PUBLIC and it worked.

Appreciate your help

Regards Kennedymr2
 
You could call the routine to TotalAll from within command button click as well like this:

Code:
Private Sub Command1_Click()
  Load Form2
  Form2.Show vbModal, me
  TotalAll
End Sub

TotalAll will only be called after Form2 unloads.

[bigcheeks]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top