INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Run a module from a acro

Run a module from a acro

(OP)
Hi

I have a macro that runs several queries and all works ok.
I also have a module called ExportContacts that I need to be part of the same macro but I cannot find a way to add it.
I have tried to add it as a RunCode but then it does not recognise the name of the module (I checked the name and it is ok)

Bit lost how I can add it in. Any ideas please.

Thanks

RE: Run a module from a acro

The name of the (standard?) module is not important.
What is important is how you declared the Sub(s) or Function(s) in this module. Are they all Private or Public?

If you have something like in the module:

CODE

Public Function Do_This(... 
You can simply do anywhere in your application:

CODE

SomeVar = Do_This 

But if they are declared as Private, they are not available from outside of the Module.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: Run a module from a acro

A possible reason for this you have used "ExportContacts" as the name instead of "ExportContacts()" - must have the brackets.

Thanks
Michael

RE: Run a module from a acro

(OP)
Hi

This is the code so not sure what is is and why it is not picking it up, how do I fix please. Thanks

Sub ExportContacts()
DoCmd.TransferText acExportDelim, "ContactsNew Export", _
"Contacts", "I:\Trex\Database 2013\ContactsNew.csv", True
End Sub

RE: Run a module from a acro

When you adding it to your macro in the "RunCode", put the Function name as "ExportContacts()".

Thanks
Michael

RE: Run a module from a acro

(OP)
HI

I have added into the macro aRinCode with the function name of ExportContacts()

When I run the macro it comes to the runcode part and gives the below

The expression you entered had a function name Microsoft Access cannot find

Any ideas please, thanks

RE: Run a module from a acro

Change it to:

CODE --> VBA

Function ExportContacts()
DoCmd.TransferText acExportDelim, "ContactsNew Export", _
"Contacts", "I:\Trex\Database 2013\ContactsNew.csv", True
End Function 

And also you can't call a Function procedure from a macro if the function name is the same as the module name.

Thanks
Michael

RE: Run a module from a acro

(OP)
Hi

Sorry guys still not working same message as before

I have a runcode with the function name of ExportContacts()

The module as this code in it

Function ExportContacts()
DoCmd.TransferText acExportDelim, "ContactsNew Export", _
"Contacts", "I:\Trex\Database 2013\ContactsNew.csv", True
End Function

But I still get The expression you entered had a function name Microsoft Access cannot find

RE: Run a module from a acro

And your module name is not named "ExportContacts"?

Thanks
Michael

RE: Run a module from a acro

(OP)
Under the Modules menu (where we have Tables/Queries/Forms etc...) is the module named
ExportContacts

RE: Run a module from a acro

Yes, do you have a module with the name "ExportContacts"? If you do, that needs to be renamed or you have to rename the Function - you can't have the function\sub and the module name the same.

Thanks
Michael

RE: Run a module from a acro

(OP)
Ok seems to have solved the issue, I renamed the module. I will give it a blast in the morning when we have new data to test with

Thanks for your help and patience.

RE: Run a module from a acro

Great, glad you got it working, you're welcome.

Thanks
Michael

RE: Run a module from a acro

(OP)
Hi

Sorry coma across another problem with it now.
have had to transfer all the tables etc... into another database so I can run it as part of another database

It keeps crashing on the module Conatctsout (the difference also is the table is now called ContactsNew, due a table already being named this in the database)

Function ExportContacts()
DoCmd.TransferText acExportDelim, "ContactsNew Export", _
"ContactsNew", "I:\Trex\Database 2013\ContactsNew.csv", True
End Function

I have a hunch it may be the "ContactsNew Export" part, which I believe I named manually when running the export from the table in the old database but I cannot recreate this procedure.

Any ideas please

RE: Run a module from a acro

(OP)
Its ok I sussed it and managed to Save As , all working again

Thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close