Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 17th, 2006, 09:02 AM
Registered User
Join Date: Oct 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Fixing a Access Database report

We have an Access Database were we have all our contacts. The Database creates an excel report for mailing publications.

The problem is that the address field may contain 2 lines. The query created for the report splits the address field in two separate columns. However, if there is a second line, the first line drops the last letter/number which causes mailing issues.

Here is the code using to split the Address field. I did not create the database but I'm trying to fix the report. Any help will be appreciated.

Address1: Str(1,Nz([Address]),Chr(13))=0,[address],Mid([address],1,InStr(1,nz([address]),Chr(13))-2))

Address2: SplitAddress(nz([address]))


Old October 18th, 2006, 07:14 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG

Address1: Iif(Instr([Address], vbCrLf)=0, [Address], Left([Address],Instr([Address], vbCrLf)-1))

Address2: Iif(Instr([Address], vbCrLf)=0, Null, Mid([Address],Instr([Address], vbCrLf)+1))

The MID function normally takes two arguments:

Mid(String, Start, Number of letters)

But if you leave out number of letters it assumes the rest of the length of the string. The long way to write it would be

Address2: Iif(Instr([Address], vbCrLf)=0, Null, Mid([Address],Instr([Address], vbCrLf)+1), Len([Address])-Instr([Address], vbCrLf)+1))

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Old October 24th, 2006, 07:31 AM
Registered User
Join Date: Oct 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Mr. Serrano,

THanks for the information, however, when I put your string in the Access query it give me a error message and when you run the query all fields say error.

Its asking for a vaule for the paramater vbCrLf.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fixing An Overbloated MDB - HELP!! dpm39560 Access 4 October 14th, 2014 05:59 AM
sub report in a password protected access database aasheesh_jha Crystal Reports 0 January 2nd, 2007 07:09 PM
Urgent...need help fixing this error! riki_gill ASP.NET 1.x and 2.0 Application Design 0 October 27th, 2006 08:23 AM
HELP! FIXING MY QUERY dstein4d Access 2 January 21st, 2006 03:24 AM
Access Database report To PDF in ASP imfriend Access ASP 1 February 4th, 2004 05:38 PM

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