p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access VBA (http://p2p.wrox.com/forumdisplay.php?f=80)
-   -   Getting Part of a String (http://p2p.wrox.com/showthread.php?t=47789)

needelp September 13th, 2006 06:57 PM

Getting Part of a String
Hi all,

i was wondering if it was possible to grab a part of a string
i have an order number that is displayed as a string eg. "06-1234"
what i wish to do is, when a new record is entered select the "1234" part of the string from the previous record, convert it to a number (i think like a Cint() type thing) increment it by 1 then convert it back to a string and put back the "06-" and put it in the new record..

i hope that makes sence

any help or advice would be much appreciated


needelp September 13th, 2006 08:17 PM

never mind... i figured it out

thanks anyway

mmcdonal September 14th, 2006 09:18 AM

So what code did you use?


needelp September 18th, 2006 06:38 PM

My order numbers are like so "06-1234" so i used the split() function
to split the string at "-" assigned the last half to a variable, converted to integer, incremented by 1, then converted back to a string and added the first half back to it

hope that makes sence

mmcdonal September 19th, 2006 06:22 AM

It might be easier to keep the two parts seperate, and then only bring them together when you need them. Like:

txtYear - default value: Left(DatePart("yyyy", Date()), 2)
intOrder - keep as increment

Then to display:

txtOrderNo: (Cstr([txtYear]) & "-" & CStr([intOrder]))

Anyway, keeps the processing down a little. Probably not much.


All times are GMT -4. The time now is 05:39 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.