Solved

Remove a character from a field for a report Access

Posted on 2014-03-17
18
166 Views
Last Modified: 2014-03-18
I have a field that has data like these examples

51A
25D
31B

This is refering to an apartment number and for the purpuses of pulling up a record I need to be able to type in 55A and have it return the Tenants for example that live in that apartment.

Because it is an address I need to seperate 55 and the A for the purposes of creating a report that says 1055 Harmony Lane. Apartment A.

Is there a way to do this in a query?
0
Comment
Question by:beatified
  • 11
  • 7
18 Comments
 
LVL 2

Author Comment

by:beatified
ID: 39935178
BTW there are a few situations that in which there is no apartment letter.

In this case seperating the number and letter is not needed but hopefully the code would be able to take this in to account.

For example there are also just numbers like

57
59
27
29

In these cases there is no apartment Letter just a number.

Obviously I would figure this would be done in a query.
0
 
LVL 26

Expert Comment

by:MacroShadow
ID: 39935187
It can be done quite easily. If you provide the sql you are using or the field names, we can provide you with a working solution.
0
 
LVL 2

Author Comment

by:beatified
ID: 39935192
The field name for the Apartment numbers is [ApartmentNum] Using Access 2010
0
 
LVL 2

Author Comment

by:beatified
ID: 39935193
[ApartmentNum] = my examples above.
0
 
LVL 26

Expert Comment

by:MacroShadow
ID: 39935257
Left([ApartmentNum], Len([ApartmentNum]) - 1) & " Apartment " & IIf(IsNumeric(Right([ApartmentNum], 1)), Right([ApartmentNum], 1), "")
0
 
LVL 2

Author Comment

by:beatified
ID: 39935317
Ok thats close but this is what it ended up getting.

Really it should be two fields in the end one with just the apartment number and one with just the apartment letter.

By the way [ApartementNum] is in [tblApartment]

My guess is the Number only field should be this...

NumOnly: Left([tblApartment].[ApartmentNum],Len([tblApartment].[ApartmentNum])-1)

But this needs some sort of IIf that says if it only has 2 characters then do nothing essentially.

But I still need one for Letter only.
Image-001.jpg
0
 
LVL 26

Expert Comment

by:MacroShadow
ID: 39935370
Sorry, should be,
Left([ApartmentNum], Len([ApartmentNum]) - 1) & IIf(IsNumeric(Right([ApartmentNum], 1)), " Apartment " & Right([ApartmentNum], 1), "")
0
 
LVL 2

Author Comment

by:beatified
ID: 39935397
Ok this is what I got this time.

Also I need another formula to return the Apartment Letter.
Image-002.jpg
0
 
LVL 26

Expert Comment

by:MacroShadow
ID: 39935533
Try this:
SELECT tblApartment.Street, tblApartment.ApartmentNum, IIf(Not IsNumeric(Right([ApartmentNum],1)),Left([ApartmentNum],Len([ApartmentNum])-1) & " Apartment " & Right([ApartmentNum],1),"") AS Expr1, IIf(Not IsNumeric(Right([ApartmentNum],1))," Apartment " & Right([ApartmentNum],1),"") AS Expr2, IIf(IsNumeric(Right([ApartmentNum],1)),[ApartmentNum],"") AS Expr3
FROM tblApartment;

Open in new window

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 2

Author Comment

by:beatified
ID: 39935557
When I put that in I get all kind of synax errors
0
 
LVL 26

Expert Comment

by:MacroShadow
ID: 39935562
Here is proof of concept.
EE-Demo.accdb
0
 
LVL 2

Author Comment

by:beatified
ID: 39935596
Ok now I see what you are doing the only problem I'm having is that if there is a letter at the end it wont return the Street number. as in exp3 for 55A
0
 
LVL 2

Author Comment

by:beatified
ID: 39935624
The Street number or exp3 should just return the first 2 characters regardless if that's possible.
0
 
LVL 2

Author Comment

by:beatified
ID: 39935629
This is dead on just need the rest of the address on the StreetNum on the other StreetNum Fields.
Image-004.jpg
0
 
LVL 26

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 39936064
Try this.
EE-Demo.accdb
0
 
LVL 2

Author Comment

by:beatified
ID: 39937309
Thanks so much man. I'm a total newb at this access stuff but by giving me the answer you have taught me so much. That may not make a ton of sense to a lot of people but for me when I see the code and can understand what it does it allows me to understand how to apply it later.

Thanks again.
0
 
LVL 2

Author Closing Comment

by:beatified
ID: 39937310
If I could give more points or a better grade I would.
0
 
LVL 26

Expert Comment

by:MacroShadow
ID: 39937461
Thanks, glad to help.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now