Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Invalid procedure call?

0 views
Skip to first unread message

Leslie Isaacs

unread,
Nov 26, 2009, 8:01:41 AM11/26/09
to
Hello All

This is a re-post of a problem I posted a while ago, but to which I got no
suggestions: hopefully I'll be more lucky this time!?

I have the following code in a Private Sub:

If InStr([ResponseXML], "element") > 0 Then
errorfield = "Invalid " & Mid([ResponseXML], InStr([ResponseXML],
"element"), InStr(InStr(InStr([ResponseXML], "element"), [ResponseXML], "'")
+ 1, [ResponseXML], "'") - InStr([ResponseXML], "element") + 1)
Else
...

Most of the time this works fine, but for some datastring values of
[ResponseXML] I get
Invalid procedure call or argument
and the code stops on the 'errorfield = ...' expression. This has occurred
where [ResponseXML] does contain the string "element" (obviously - otherwise
the code wouldn't get past the condition into the expression!). The curious
thing is that if I use the exact same errorfield expression in a query, on
the same value of [ResponseXML], it returns the expected result (which is
<Invalid Element 'TaxCodeAtLeaving'> - without the <>s). I could understand
it if I'd just got duff syntax, but the fact that the query works ...?

In case it helps, one value of [ResponseXML] where this problem occurs is
below.

Hope someone can help
Many thanks
Leslie Isaacs


Problem value of [ResponseXML] follows:

...................HTTP Text: 200 OK
Request: submit_poll
Response: submit_error
CorrelationID: C3CFE512E3EB40D0B93A3A43A01348B1
Info: : The submission of this document has failed due to departmental
specific business logic in the Body tag.
The submission of this document has failed due to departmental specific
business logic in the Body tag.
<?xml version="1.0"?><GovTalkMessage
xmlns="http://www.govtalk.gov.uk/CM/envelope"><EnvelopeVersion>1.0</EnvelopeVersion><Header><MessageDetails><Class>IR-PAYE-MOV</Class><Qualifier>error</Qualifier><Function>submit</Function><TransactionID></TransactionID><CorrelationID>C3CFE512E3EB40D0B93A3A43A01348B1</CorrelationID><ResponseEndPoint
PollInterval="10">https://secure.gateway.gov.uk/poll</ResponseEndPoint><GatewayTimestamp>2009-11-12T15:55:39.662</GatewayTimestamp></MessageDetails><SenderDetails
/></Header><GovTalkDetails><Keys
/><GovTalkErrors><Error><RaisedBy>Department</RaisedBy><Number>3001</Number><Type>business</Type><Text>The
submission of this document has failed due to departmental specific business
logic in the Body tag.</Text></Error></GovTalkErrors></GovTalkDetails><Body>
<ErrorResponse xmlns="http://www.govtalk.gov.uk/CM/errorresponse"
SchemaVersion="2.0">
<Application>
<MessageCount>2</MessageCount>
</Application>
<Error>
<RaisedBy>ChRIS</RaisedBy>
<Number>4085</Number>
<Type>schema</Type>
<Text>Value '0NT' doesn't have the correct format</Text>
<Location>/hd:GovTalkMessage[1]/hd:Body[1]/mov:IRenvelope[1]/mov:InYearMovements[1]/mov:P45Part1[1]/mov:TaxCodeAtLeaving[1]</Location>
<Application>
<Messages xmlns="http://www.govtalk.gov.uk/validation/messages/1">
<ServiceMessage>
<UserText number="7674">Tax code entered is not a valid code.</UserText>
</ServiceMessage>
<DeveloperMessage>cvc-pattern-valid: Value '0NT' is not facet-valid with
respect to pattern
'([1-9][0-9]{0,5}[LPTVY])|(BR)|(0T)|(NT)|(FT)|(D0)|([K][1-9][0-9]{0,5})' for
type '_intermediate_TaxCodeStructure'.</DeveloperMessage>
</Messages>
</Application>
</Error>
<Error>
<RaisedBy>ChRIS</RaisedBy>
<Number>4052</Number>
<Type>schema</Type>
<Text>Element 'TaxCodeAtLeaving' must only have valid text as its
content</Text>
<Location>/hd:GovTalkMessage[1]/hd:Body[1]/mov:IRenvelope[1]/mov:InYearMovements[1]/mov:P45Part1[1]/mov:TaxCodeAtLeaving[1]</Location>
<Application>
<Messages xmlns="http://www.govtalk.gov.uk/validation/messages/1">
<ServiceMessage>
<UserText number="7674">Tax code entered is not a valid code.</UserText>
</ServiceMessage>
<DeveloperMessage>cvc-complex-type.2.2: Element 'TaxCodeAtLeaving' must have
no element [children], and the value must be valid.</DeveloperMessage>
</Messages>
</Application>
</Error>
</ErrorResponse>
</Body>
</GovTalkMessage>

Ken Snell

unread,
Nov 26, 2009, 9:35:51 AM11/26/09
to
To debug your problem, add MsgBox steps into the code to show you the values
being calculated for all your InStr and Mid arguments. That should show you
where the code is "going wrong".

If InStr([ResponseXML], "element") > 0 Then

MsgBox InStr([ResponseXML],"element")
MsgBox InStr([ResponseXML], "element"), [ResponseXML], "'") + 1
MsgBox InStr(InStr(InStr([ResponseXML], "element"), [ResponseXML], "'") + 1,
[ResponseXML], "'")
MsgBox InStr([ResponseXML], "element") + 1
MsgBox InStr(InStr(InStr([ResponseXML], "element"), [ResponseXML], "'") + 1,

[ResponseXML], "'") - InStr([ResponseXML], "element") + 1

errorfield = "Invalid " & Mid([ResponseXML], InStr([ResponseXML],
"element"), InStr(InStr(InStr([ResponseXML], "element"), [ResponseXML], "'")
+ 1, [ResponseXML], "'") - InStr([ResponseXML], "element") + 1)
Else
...

--

Ken Snell
http://www.accessmvp.com/KDSnell/

"Leslie Isaacs" <les...@gppayroll.org.uk> wrote in message
news:OWCebipb...@TK2MSFTNGP05.phx.gbl...

Tony Toews [MVP]

unread,
Nov 27, 2009, 12:05:25 AM11/27/09
to
"Leslie Isaacs" <les...@gppayroll.org.uk> wrote:

>This is a re-post of a problem I posted a while ago, but to which I got no
>suggestions: hopefully I'll be more lucky this time!?
>
>I have the following code in a Private Sub:
>
>If InStr([ResponseXML], "element") > 0 Then
>errorfield = "Invalid " & Mid([ResponseXML], InStr([ResponseXML],
>"element"), InStr(InStr(InStr([ResponseXML], "element"), [ResponseXML], "'")
>+ 1, [ResponseXML], "'") - InStr([ResponseXML], "element") + 1)
>Else

One thing I'd do is simplify the code a bit.

Dim ElementPosn as long
ElementPosn = InStr([ResponseXML], "element")

then change the above code to use ElementPosn

errorfield = "Invalid " & Mid([ResponseXML], ElementPosn ,
InStr(InStr(ElementPosn, [ResponseXML], "'")
+ 1, [ResponseXML], "'") - ElementPosn + 1)

Of course I don't have various brackets and such matched up but I
suspect this might make it easier to figure out logic problems.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a free, convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/

Leslie Isaacs

unread,
Nov 27, 2009, 5:14:37 AM11/27/09
to
Hello Ken

Many thanks for your reply. I will try the msgboxes as you suggested - great
idea!

I'll come back with any problems.
Thanks again
Les


"Ken Snell" <kthsne...@ncoomcastt.renaetl> wrote in message
news:OSaACXqb...@TK2MSFTNGP02.phx.gbl...

Leslie Isaacs

unread,
Nov 27, 2009, 5:18:40 AM11/27/09
to
Hello Tony

Good idea!

I could obviously use the same technique to improve the readability of the
other arguments, and also using Ken's suggestion of the msgboxes I should be
able to figure it out (but will come back here if I can't!).

Many thanks for your help
Les


"Tony Toews [MVP]" <tto...@telusplanet.net> wrote in message
news:e9nug5digbosjhso1...@4ax.com...

Crystal (strive4peace)

unread,
Nov 29, 2009, 9:41:50 PM11/29/09
to
Hi Leslie,

lets simplify this a bit by creating some variables -- this
will also enable us to do testing

'~~~~~~~~~~
dim mPosElement as integer _
, mPosQuote1 as integer _
, mPosQuote2 as integer

mPosElement = InStr([ResponseXML], "element")

if mPosElement > 0 then
mPosQuote1 = InStr( _
mPosElement, [ResponseXML], "'")

if mPosQuote1 > 0 then

mPosQuote2 = _
InStr(mPosQuote+ 1, [ResponseXML], "'")

if mPosQuote2 > 0 then
errorfield = "Invalid " _
& Mid([ResponseXML] _
, mPosElement _
, mPosQuote2 - mPosElement + 1)
end if
end if
end if
'~~~~~~~~~~~~~~~~~

I suspect that you got errors on records where the 2 quotes
weren't found after "element" and you were not testing to
make sure they were there before doing the assignment. I do
see an example of this with "... no element [children]..."

now why the query is forgiving ... well it uses something
different to process the logic than VBA

Warm Regards,
Crystal
remote programming and training
http://MSAccessGurus.com

free video tutorials
http://www.YouTube.com/user/LearnAccessByCrystal

Access Basics
http://www.AccessMVP.com/strive4peace
free 100-page book that covers essentials in Access

*
(: have an awesome day :)
*

0 new messages