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

Module help 1

Status
Not open for further replies.

mrrrl

MIS
Dec 26, 2001
179
US
I have a long main program code on a form that I would like to put some of the procedures into modules to be able to use form other procedures and forms. I have a procedure that saves some data into an access database. I move all the code over to the module. Then in the main I call the procedure but only get the follow error:

expected a variable or procedure not module

I don't understand. Why will it not run the module? I am not passing the module any data, for now it is self contained until I get it to work.

TIA
 
Assuming that your module contains procedures like:
[tt]
Public Sub mySub
' your procedure
' here
End Sub
[/tt]
Then to run mySub from a Form Load:
[tt]
Private Sub Form_Load()
mySub
End Sub
[/tt]

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Also, if you give the Sub or Function the same name as the module then you will see that message. For example
[blue][tt]
In Module "myModule.Bas"

Public Sub myModule()
' Some Code
End Sub
[/tt][/blue]
And then you attempt, somewhere in a form
[blue][tt]
Call myModule
[/tt][/blue]
you will see that error. Use a module name that does not duplicate the names of the Sub or Function points in the module.
 
Thanks for the help. I found out that the problem is that you can't name the module and the procedure the same. If I changed one or the other it worked just fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top