Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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 October 15th, 2004, 01:41 PM
Registered User
 
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Prefix zero conditionally: A newbie question

Hi,
I'm relatively new to VBA/Access. I have a field (text format) which contains items (of about 5000) of length 12 or 13 in an Access table. I want to prefix a "0" before all items having a length of 12 to make it 13. How can I do that? Where should i do that?? I tried putting an IF statement in VBA editor, but returned with syntax error. Please help
Thanks
Soorya
 
Old October 18th, 2004, 03:13 AM
Authorized User
 
Join Date: Jul 2003
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try:
if len(strText) = 12 then
    strText = "0" & strText
end if

Cheers Ray
 
Old October 18th, 2004, 12:17 PM
Registered User
 
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Ray. I was trying to implement similar logic in Access, but had a hard time getting reference to field in Access table and update it with this logic.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie question peterh Classic ASP Databases 3 January 17th, 2008 12:25 PM
Newbie Question - Sorry! KP Crystal Reports 1 June 13th, 2006 02:45 AM
C# Newbie Question jazzcatone ASP.NET 2.0 Basics 1 May 25th, 2006 10:18 PM
newbie question Warbird XML 0 May 11th, 2005 08:41 AM
Newbie question Beginner VB.NET 2002/2003 Basics 2 November 9th, 2003 07:58 AM





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