Re: Function returns Datatype Mismatch
- From: "davidg2356" <davidg2356@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 15 Apr 2005 13:27:02 -0700
Thanks for your help that works great.
Sincerely,
David Greer
"Dirk Goldgar" wrote:
> "davidg2356" <davidg2356@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:F52C4F53-13C3-4697-AA7B-128F2F8FEA03@xxxxxxxxxxxxx
> > Hi,
> >
> > I am attempting to split a part an account code to extract part of
> > it, and some great people here have given me some code to aid in this
> > endeavor. (I have now read a few chapters about Visual Basic),
> > however I am encountering the following error:
> >
> > Run-time Error '13':
> > Type Mismatch
> >
> > The Accounting_Code in my table has a Text datatype.
> >
> > VB Procedure:
> >
> > Public Function Extract(Account_Code As String) As String
> > Dim Tokens() As String
> > Tokens = Split(Account_Code, ".", -1)
> > Extract = Mid(Tokens, 4, 4)
> > End Function
> >
> > Update Query:
> >
> > UPDATE SUB_1 SET SUB_1.Clearing_Account = Extract([Clearing_Account]);
> >
> > Visual Basic Editor is highlighting the "Extract = Mid(Tokens, 4, 4)"
> > line of code from my procedure, but as far as I know everything is
> > setup as text so there should not be a problem. ???
> >
> > Thanks for your time,
> > David
>
> Your code doesn't quite make sense. Tokens is an array of strings,
> which you are creating by splitting Account_Code on the "." character.
> Then you're trying to use the Mid function on the array itself -- but
> Mid() requires a string argument, not an array argument. Which part of
> Account_Code do you want? If you want the fourth element, you would
> just right
>
> Extract = Tokens(3)
>
> because the array is zero-based. Suppose you had an Account_Code of
> "A.B.C.D.E". Then
>
> Tokens(0) yields "A"
> Tokens(1) yields "B"
> Tokens(2) yields "C"
> Tokens(3) yields "D"
> Tokens(4) yields "E"
>
> If that explanation doesn't help, please tell us what you actually want
> Extract to return.
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>
>
.
- References:
- Function returns Datatype Mismatch
- From: davidg2356
- Re: Function returns Datatype Mismatch
- From: Dirk Goldgar
- Function returns Datatype Mismatch
- Prev by Date: No Current Record
- Next by Date: Re: TIME LOOP CODE
- Previous by thread: Re: Function returns Datatype Mismatch
- Next by thread: RE: Function returns Datatype Mismatch
- Index(es):
Relevant Pages
|