how do one call a sub from another sub(function)?

M

michelle

I have tried 'call subname'
then I get 'object variable or with-blockvariable in not indicated',(
that my own translation swedish to english).
 
G

Guest

There is a different if you call a sub or function.

To Run a sub, you use
Call SubName()

To Run a function
Either
FunctionName

Or
x = FunctionName()
when x is a variable you need to define
 
G

Guest

Sorry, I just tried it and you can use

Call FunctionName

Did you define this Sub in a module, and not in a form?
 
M

michelle

Thanks for yor reply, unfortunately non of yor suggestion works.
I get the same error as before.
The first function, cmdAddPicture_click(), is run from a form, the
second is a function,cmdSavePost_Click(), which ias run when a button
'save' is pressed.

I thoughtI had declared the furst funtion in the second function with
Dim cmdAddPicture As Access.Application
but perhaps that isn't the way to do it.

Thanks for helping
/Michelle
 
G

Guest

The two Sub's cmdAddPicture_click() and cmdSavePost_Click() are they located
on the same form?

If they do, there is no need to declare it, just run it
Call cmdAddPicture()

The declaretin (Dim cmdAddPicture As Access.Application) can cause this
error that you are getting, remove it.
 
G

Guest

To call a sub on another form try

Form_FormName.SubName

change it to the right names
========================
But why do you need to call a sub on another form?
The proper way to it is, to create a Sub or Function in a module and then
you can call it from both forms.
 
M

michelle

Doesn't either work.
Is it possible that I'll send you tha whol db so you can check fot
yourself?
It's 4.3 kb.

/Mi
 
G

Guest

Send it to

chamudim <at> hotmail <dot> com

and please explain which function you are trying to run and on which form,
and from where.
 

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