Argument not optional

D

Dudley

I am trying to create a command button to run public sub
IncorporationQuery(Envelope as String). For code

Dim strGetProc As String
strGetProc = "IncorporationQuery"
Application.Run strGetProc

I get error 'Argument not optional'. I cannot find how to write the argument.

Thanks for any help.
Dudley
 
J

Jeff Boyce

Have you tried checking Access HELP for the proper syntax for your command?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
C

Compugasm

Dudley said:
I get error 'Argument not optional'. I cannot find how to write the argument.

Your Sub "IncorporationQuery" is expecting the argument "Envelope" as a
string. But, you aren't passing it anything, and that is causing the error.
Somewhere in your code you have something like this:

Call IncorporationQuery("myText")

The "myText" is string argument passed into the function, which the function
"IncorporationQuery" will consider to be (Envelope as String). Then, what you
want to do with the variables is something like:

strGetProc = Envelope

This will set the value of strGetProc to "myText".

Or, what you could do is make the Envelope argument Optional, and that will
take care of the error too. Like this:

Public Sub IncorporationQuery(Optional Envelope as String)

That's all there is to it.
 
D

Dudley

Thanks very much for your help. My error was putting the argument as
"Envelope as String" instead of "Envelope".

Dudley
 

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