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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

closing forms 1

Status
Not open for further replies.

uscitizen

Technical User
Jan 17, 2003
672
US
i'm a newbie wrt vba and w/ that said....

i have a bunch of forms and while i could create a bunch of macros each of which would be written to get triggered to close a form when a command button atop the form's 'clicked' i have a sneaking suspicion that some 'function' could be written and made 'universal' (if that is the proper term) that could be activated to 'close the current form' when the command button's clicked. i'm looking to use one function without having to expressly name the form it's going to close. sound doable?
 
well, you can use the keyword "Me"
as in
me.hide
me.unload
BUT
it will not work outside of the userform module that holds the code for that particular userform so, we have to pass the form object thru the sub

In a standard module:

Sub Closer(frm As Object)
frm.Hide
End Sub


in the code for the button that closes the form:
call Closer(me)

HTH

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
thanks!
i just 'discovered' the command button wizard which seems to let you interactively pick from a small collection of functionalities what you'd like your button clicking to do.

i would like to learn more wrt vba though (as i doubt i'll be quite as fortunate in every quest) and there's no shortage of 'good' books -- problem is there's too many.

decisions, decisions...
 
Well, I have never extensively used a reference book for VBA - I just use the help files, the object model, this forum and an excel developers mailing list that I am subscribed to. That said, the one that crops up a lot is John Walkenbach's power programming series

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top