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

Eliminating Macros from Custom toolbars

Status
Not open for further replies.

AlanKW

Technical User
Jun 20, 2002
161
0
0
US
I am updating some databases from Access97 to AccessXP. I am trying to clean up the databases in the process (eliminating unused forms, reports, etc…). There were some macros that I changed to code and eliminated the macros and everything, but there is a custom toolbar with some buttons that are tied to Macros. Is there a way that I can have the button goto a function so I can be completely Macro free?

Thanks in advance
-Alan
 
Yes create Public functions
then in the OnAction of the propertys of your menu item
enter =functionname()
 
is it possible to have the menu item call a sub, or does it have to be a function?

I have multiple subs (cmdUpdateCustomerInfo(), cmdAddNew(), etc) and would like to add these functions to my customer toolbar. Is this possible? If not, how would I go about changing them to functions?
 
nimarii,
I believe this is only possible with functions.
In order to change a sub to function, you must, of course, change the stub Public Sub/End Sub to Public Function/End Function. Then, in this case, the name of your function, must equal, the result of your code....

before...
Sub AddNumbers()

dim x,y w as integer

x= 7: y = 12

w = (x + y)
txtBox = w
End Sub

after..
Public Function AddNumbers() As integer

dim x, y, w as integer

x= 7: y = 12

w = (x + y)
AddNumbers = w
End Function

Then to call it from a controlSource of a textbox, for example,
ControlSource = AddNumber()

Hope this helps, good luck!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top