Cannot run module in macro

  • Thread starter JACKGUNAWAN via AccessMonster.com
  • Start date
J

JACKGUNAWAN via AccessMonster.com

Hi,

I have a module of :
Public Sub DELETES()
Kill "C:\export\*.*"
End Sub

I try to run in macro with runcode however in the function name, the macro
cannot paste it in the expression builder. Please guide. Thank you.


Jack
 
J

Jack Leach

Macros cannto run subs, but they can run a function. Change Public Sub to
Public Function instead (it need not return a value, that should be the only
thing you have to find).

This is true also when trying to reference functions from object
properties/queries, etc. Only functions, not subs.

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
T

tom_willpa

high quality Soccer jerseys NBA Jersey tracksuit and jackets, GHD
hairstraightener supplier from www.willpa.com

Are you a Retail businessman who bother by the purchase price? China
Cheapest TOP wholesale website can help you

we are specialize in replica sport goods manufacturing in china, we can
offer you all kinds of soccer jersey, NBA jersey,shoes and so on. they are
the best brand replica goods whih are look the same as the original goods.
excellent quality and steady supply for them. we have been marketed in Europe
and American for 3 year. all the goods we offer are AAA quality. our soccer
jersey are Thailand style. If any goods you buy from my company have problem,
we will refund or resend them again. Most of ourProducts have no minimum
order requirements,soyou can shop retail goods at wholesale prices. if you
can buy more than 300usd. We offer free shipping. The more you buy the more
discount for you.

National soccer jerseys: http://www.willpa.com
Club soccer jerseys: http://www.willpa.com
NBA Jerseys: http://www.willpa.com
T-shirt and shirt: http://www.willpa.com
Tracksuit: http://www.willpa.com
Hoody & Jackets: http://www.willpa.com
UGG boots: http://www.willpa.com
Hair style: http://www.willpa.com
shopping Index: http://www.willpa.com

EMS shipping. 7days arrive, paypal accept

want more information pls contact us or check our website: www.willpa.com
 
J

JimBurke via AccessMonster.com

Also, when you put the function name parameter in the Macro you must put
parentheses after it!

Jack said:
Macros cannto run subs, but they can run a function. Change Public Sub to
Public Function instead (it need not return a value, that should be the only
thing you have to find).

This is true also when trying to reference functions from object
properties/queries, etc. Only functions, not subs.

hth
[quoted text clipped - 7 lines]
 
J

JACKGUNAWAN via AccessMonster.com

Hi Jack,

Thank for the guide.

My code is now:
Public Function DEL()

Kill "C:\export\*.*"

End Function


However when I run in macro, a message box came "The expression you entered
has a function name that access can't find" and I can't run the macro. thanks
 
J

Jack Leach

Per Jim's suggestion, have you included the parentheses at the end in the
macro?

Also, this function must reside in a standard module, not in a form or
report module. If this is part of a form or report module you will have to
move it.

One last things, which may or may not be causing a problem, is the function
name itself. DEL may have uses elsewhere in your project... I would
recommend prefixing the function name with an "f" or something like, just to
make sure there's no internal conflict (for more info on this concept see
http://www.utteraccess.com/wiki/index.php/Naming_Conventions )

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
J

JACKGUNAWAN via AccessMonster.com

Hi Jack,

Yes it works! Thanks for the assistance Jack.


Jack
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top