Darren - Active Billing
darren at activebilling.com.au
Tue Jan 26 23:30:58 CST 2010
Hi guys Thanks for the responses I actually got it working - WooHoo Turns out instr() will look for the beginning position of a string Dufus here thought it would only look for the beginning position of a single character So I got the beginning of [InvoiceNo] and the next comma after it Then I uses a mid to get the invoice number Many thanks for the responses guys Darren -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Wednesday, 27 January 2010 3:33 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] A2003:Replacing 'tokens' in a string Note: the function below does not require the square brackets around the Token. Usage: Getvalue(strTokenList, "InvoiceNo") If you want to use the brackets in the call to allow for a case where the token name may also appear in another token's value, you will need to change the 2 to 1 in the code and the call would be: Getvalue(strTokenList, "[InvoiceNo]") Function GetValue(TokenList As String, Token As String) As String Dim lngStart As Long Dim lngEnd As Long lngStart = InStr(TokenList, Token) + Len(Token) + 2 lngEnd = InStr(lngStart, TokenList, """") GetValue = Mid$(TokenList, lngStart, lngEnd - lngStart) End Function -- Stuart On 27 Jan 2010 at 13:31, Darren - Active Billing wrote: > Hi team > > Assuming the string below > > "[AccountNo]=1234","[InvoiceNo]=1234567","[InvoiceDate]=04/01/2010","[Name]= > Barry" > > How would I get just the Invoice Number bit = Eg 1234567? > > The 'token' [InvoiceNo] will be constant followed by an "=" sign > > But sadly the position of the [InvoiceNo] token in the string will not be > constant - Otherwise I'd just use MID() > > Nor will the length of the invoice number - Some may be 4 digits others 6 > etc > > I need to pull just the Invoice Number (And the Account Number) out of the > string to build a new string being used elsewhere > > Many thanks in advance > > Darren > > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com