Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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

Reply With Quote
  #2 (permalink)  
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

Reply With Quote
  #3 (permalink)  
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
Reply With Quote
  #4 (permalink)  
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

Reply With Quote
  #5 (permalink)  
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:18 AM.


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