Solved

Activate Command

Posted on 2009-04-02
4
244 Views
Last Modified: 2012-05-06
How to activate the command to  the main form from other form?
example: My Main form is mainfrm then the other form is form1.
in mainfrm i have a code like this
Public sub kick()
msgbox "hello"
end sub
now i go to form1, then i want to activate kick upon downloading the form1. here's my command

Private Sub Command1_Click()
Unload me
kick
End Sub

My code is not working.
Please give some example to do this?
Thanks!
 
0
Comment
Question by:Whing Dela Cruz
4 Comments
 
LVL 1

Assisted Solution

by:deepakra79
deepakra79 earned 150 total points
ID: 24047559
You need to call mainfrm.kick as below

Private Sub Command1_Click()
Unload me
mainfrm.kick
End Sub

To call any function directly it should be in module instead of form.
0
 
LVL 11

Accepted Solution

by:
bmatumbura earned 200 total points
ID: 24047593

Private Sub Command1_Click()

  Me.Visible=False

  kick

  Unload me

End Sub

Open in new window

0
 
LVL 11

Assisted Solution

by:Antagony1960
Antagony1960 earned 150 total points
ID: 24047627
Also, you're having form1 unload itself and then continuing to run code from within that form's module. Strictly speaking the unload command should be very the last thing it does. You'd get away with it in this instance but any significant amount of code following the unload command may prevent the form from unloading. This is the better way to do it:

Private Sub Command1_Click()
Me.Hide
mainfrm.kick
Unload Me
End Sub
0
 

Author Closing Comment

by:Whing Dela Cruz
ID: 31565683
Thanks to guys!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now