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

Invalid Procedure in shell command

Status
Not open for further replies.

MDJ52

MIS
Mar 30, 2001
120
0
0
US
This code is running within an MSAccess program and is used to send faxes to our fax server.
The code worked fine until recently when we began to get an error code 5 with a message of "Invalid Procedure Call or Argument" This program runs on a number of desktops using XP, SP3.
*********start of code*************
Function CreateFaxdup() As Variant
Dim mydb As DAO.Database
Dim my1 As DAO.Recordset
Dim Inits As String
Dim delayend As Double
Dim huserid As String
Dim faxhold As String
Dim faxH As String
Dim FaxArea As String
Dim FaxPrefix As String
Dim FaxSuffix As String
Dim rfqrpt1 As String
Dim cnt As Integer

Set mydb = CurrentDb
Set my1 = mydb.OpenRecordset("cust_sel_file1")
huserid = Environ("username")
rfqrpt1 = "c:\prtfile\rptq1.pdf"
my1.MoveFirst

'*************Report 1****************
If Forms!form3!Pcntl = 1 Then
DoCmd.OpenReport "quickquote_em_new"
Else
DoCmd.OpenReport "quickquote_em_new_xx"
End If

delayend = DateAdd("s", 2, Now)
While DateDiff("s", Now, delayend) > 0
Wend

If Len(my1!CustFaxNo) = 7 Then
faxhold = my1!CustFaxNo
ElseIf Len(my1!CustFaxNo) = 8 Then
faxhold = Left(my1!CustFaxNo, 3) + Mid(my1!CustFaxNo, 5, 4)
ElseIf Len(my1!CustFaxNo) = 10 Then
faxhold = "1" + my1!CustFaxNo
ElseIf Len(my1!CustFaxNo) = 12 Then
faxhold = "1" + Left(my1!CustFaxNo, 3) + Mid(my1!CustFaxNo, 5, 3) + Right(my1!CustFaxNo, 4)
End If

Inits = "\\fax\faxpress\submitfax /sfaxpress4 /oc:\prtfile /u" + huserid + " /r" + faxhold + " /a" + rfqrpt1
shell (Inits)

error99:
On Error Resume Next
'Kill rfqhold
Set my1 = Nothing
Set mydb = Nothing
End Function
***********end of code****************
 
what line does it error om?

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
The error of invalid procedure is occurring when it trys to execute the 'shell' command.
 
Is the Shell command a valid syntax? What is it calling?

Gerry
 
Have you (can you) spawn this from DOS to check the syntax?

sam
 
The shell command calls the command line created in the code just before it.
I can take this command and place a 'cmd' set in front of it and run it through the run line on the start menu and it works fine. Just seems to be when it is in the shell line.
 



Do a Debug.Print Inits

and determine if that's what you really want.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Yes, I did test with a print command. The inits line does fill and update properly. We have also checked where we received the layout example. This same line is used in a command line in our ERP software. In that case it is in a cobol program. We use the cobol every night to ceate and send invoices. The program is used all day to generate PO's. The error only seems to be when used as a shell command out of the access program.
 
The error only seems to be when used as a shell command out of the access program.

Maybe try creating a batch file out of your command string then shell the batch; just a thought because if you claim the command string is good I can't see any reason why it's ain't working.


Code:
Open "C:\My.bat" For Output As #1
Inits = "\\fax\faxpress\submitfax /sfaxpress4 /oc:\prtfile /u" + huserid + " /r" + faxhold + " /a" + rfqrpt1
Print #1, Inits;
Close #1
Shell ("C:\My.bat")
 
Yes, we tried that one also.
We also tried to make it a cmd file with a cmd parameter on the front of it.
Neither of these solutions worked.
 
Hmmmm Interesting, I guess I'd next try something like VooDoo, maybe your program simply has some bad Mojo!

Whatever it is please post your fix when you find it.

 
Do you need a space or dash between the switches and the arguments?

Right now you have /uhuserid and /rfaxhold.
Maybe should be /u huserid and /r faxhold?
 
We contacted the software company for Faxpress to verify the parameters. All are correct and they are designed to have the qualifier and data with no spaces.
 
Does one of your parameter values contain spaces?
You might try this:
Code:
Inits = "\\fax\faxpress\submitfax /sfaxpress4 /oc:\prtfile /u" & chr(34) & huserid & chr(34) & " /r" &  & chr(34) & faxhold  & chr(34) & " /a"  & chr(34) & rfqrpt1  & chr(34)

This will enclose all your param values in quotes.


[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
I guess that I would next eliminate the possibility that the problem is with "Inits" and at same time see if the "shell" works on a very simple command.

Open "C:\My.bat" For Output As #1
Inits = "dir c: > output.txt"
Print #1, Inits;
Close #1
Shell ("C:\My.bat")

go to a DOS prompt and see if c:\output.txt exists.
 
This is the version of what I did.
*********************
Function test()
Dim inits As String

Open "c:\my.bat" For Output As #1
inits = "dir c:>c:\output.txt"
Print #1, inits
Close #1
shell ("c:\my.bat")

End Function
**********************
It worked just fine. The other interesting part is it gave me the directory list of the Windows directory.
So it appears the shell command can work. Why it pointed to Windows I do not know or why it worked in this simple little program I do not know. But it seems to be a start.
 
maybe error code 5 means it can't find
\\fax\faxpress\submitfax ???

Can you map a drive to wherever \\fax\faxpress\submitfax resides?

can you get your little above test to work where \\fax\faxpress\submitfax resides?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top