Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 13th, 2006, 06:57 PM
Authorized User
 
Join Date: Sep 2006
Location: , , Australia.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting Part of a String

Hi all,

i was wondering if it was possible to grab a part of a string
eg.
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

cheers

 
Old September 13th, 2006, 08:17 PM
Authorized User
 
Join Date: Sep 2006
Location: , , Australia.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

never mind... i figured it out

thanks anyway

 
Old September 14th, 2006, 09:18 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

So what code did you use?

mmcdonal
 
Old September 18th, 2006, 06:38 PM
Authorized User
 
Join Date: Sep 2006
Location: , , Australia.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old September 19th, 2006, 06:22 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

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

tblYourTable
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.



mmcdonal




Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract part of String carrie09 Access 6 August 24th, 2007 10:04 AM
variable to equal part of string melkin Classic ASP Basics 28 May 17th, 2007 01:08 PM
Convert Part of String to Date twsinc Access VBA 6 October 20th, 2004 03:31 PM
Conversion part of string to date MRvLuijpen Access 5 May 18th, 2004 02:31 PM
A query to extract part of a string RayL Access 3 March 10th, 2004 09:42 AM





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