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
Password Reminder
Register
| FAQ | Members List | 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 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 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]))

THanks



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

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
Reply With Quote
  #3 (permalink)  
Old October 24th, 2006, 07:31 AM
Registered User
 
Join Date: Oct 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.



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



All times are GMT -4. The time now is 09:46 PM.


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