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

I"M BACK!! =-]

Status
Not open for further replies.

Jarnut00

Technical User
Jan 24, 2002
32
0
0
US
Hey all..I just wanted to say thanx again for the help I received last time...here again with a wacky one.

I am working in Acesss XP ...
I have a form with several command buttons to open different forms. I would like to know If I could create a module somewhere along the lines of

Code:
IF "camdbuttonname = "composition" then
      docmd.openform "compositon",,,,,acwindownormal

but use a global term like "cmdname" and make them strings

dim cmdname as string
dim camdbutton composition as string

I don't know the best way to do it or to ecen try to explain it..

basicaly I want a global name so that when I click on the button it reads the buttons name and opens the matching form...

I would like to be able to assign the SAME CODE to the several different buttons on one form to open the matching form.
There are 27 different buttons and I dont wanna have to make 27 different macros to do the same action...
 
Hi!

You can create a public function like this:

Public Function OpenMyForms()

Dim ctl As Control
Dim strFormName As String

Set ctl = Screen.ActiveControl
strFormname = "frm" & Mid(ctl.Name, 4)

DoCmd.OpenForm strFormName, , , , , acWindowNormal

End Function

Then go to the event tab in the property sheet for each button and type =OpenMyForms(). You will want to name your forms frmXXXXXX and the buttons cmdXXXXXX.

hth
Jeff Bridgham
bridgham@purdue.edu
 
I'm not trying to insult intelligence here...trust I couldn't figure it out so I came here...

but If I typed =OpenMyForms=() into the TAB of the properties...how would It work when I clicked the button?

would I wanna make it a module and "onclick" run module ?
 
Hi!

Sorry, I guess I was typing too fast. On the Event tab of the property sheets in the On Click box type =OpenMyForms().

hth
Jeff Bridgham
bridgham@purdue.edu
 
Thanks for the help....
After renaming ALL of my forms..it works nice
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top