Solved

Report Translate letters to numbers

Posted on 2014-03-10
13
248 Views
Last Modified: 2014-03-10
I have a cell of a table that has numbers stored as letters. On the report, I need the result to be the letters translated back to numbers. The table cell with the letters is set1. The letters numeric value is:

q = 0, w = 1, e = 2, r = 3, t = 4,  y = 5, u = 6, i = 7, p = 8, a = 9

Any idea how I would do this on a report?

Thanks!

Chris
0
Comment
Question by:cansevin
  • 7
  • 6
13 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39918475
Not clear what exactly your table structure and data is like.

Does your table have two fields - one for the letter and another for its corresponding number?

If so, you can get a letter's number by setting the control source of a text box as follows:

= DLookup("YourNumberField", "YourTableName", "YourLetterField = '" & YourLetter & "'")

Open in new window

0
 

Author Comment

by:cansevin
ID: 39918481
The table only has the info with the letters. The numbers is not saved on a table. That is why it will somehow need to translate it back to numbers. Any ideas?
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39918529
Then how do you know (generically) which letters correspond to which numbers...?

Or are we talking about ONLY those letters, with exact matches to ONLY those numbers?

If you have any control over the table design as a developer, I would suggest *adding* a field to that table so that you can map each letter to a unique number.  By doing that, you can easily 'look up' any number from a letter (or vice versa) using the DLookup syntax in my earlier comment.
0
 

Author Comment

by:cansevin
ID: 39918544
Sorry for the confusion there... those are the only letters that will ever be in the value. So it is a straight translation. There will never be any other letters to translate. Totally understand it would be easier if there was more info in the table. Unfortunately, I can't control that.

Thanks!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39918549
<<  I would suggest *adding* a field to that table so that you can map each letter to a unique number.>>

Actually, re-reading your question... to be clear, what I am suggesting is to create a separate Lookup Table if you don't have one already, called tblLookupNumbers that simply looks like this:

Letter    Num
   Q             0
    W           1
    E              2
    R              3
     T             4
     Y             5
     U            6
      I             7

Then the textbox control source would be this:

= DLookup("Num", "tblLookupNumber", "Letter= '" & YourLetter & "'")

Open in new window

0
 
LVL 61

Expert Comment

by:mbizup
ID: 39918555
<<
Totally understand it would be easier if there was more info in the table. Unfortunately, I can't control that.
>>

A separate lookup table should be possible, even if you don't have control over the table you have been describing.  The Lookup Table can be part of the Front-End interface that contains your report.
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 

Author Comment

by:cansevin
ID: 39918557
Ok... would that option work for a string of letters. For example:

wwrrtt would show up "113344"
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39918572
It would work for mapping letters to numbers.  But for a string of letters (with or without a lookup table), you would need code to parse the string letter by letter, replacing the letters with their corresponding numbers.

I don't have the time to help with that at the moment, but perhaps someone else does - and I'll check back in later this evening otherwise.
0
 

Author Comment

by:cansevin
ID: 39918590
Totally understand... thanks!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39918997
You can use a series of nested Replace commands, like this:


Replace(Replace(Replace(Replace(YourString, "Q","0"), "W","1"),"E","2"),"R","3")  ... etc

Open in new window

Or in a more readable format:


s = Replace(YourString, "Q","0")
s = Replace(s, "W","1")
s = Replace(s, "E","2")
s = Replace(s, "R","3")
s = Replace(s, "T","4")
s = Replace(s, "Y","5")

' etc

Open in new window



That can either be done harcoded as above, or using a lookup table (described earlier) which is more flexible if you might ever need to add to or change these mappings:


s = Replace(YourString, "Q", DLookup("Num", "tblLookupNumber", "Letter= 'Q'"))
s = Replace(s, "W", DLookup("Num", "tblLookupNumber", "Letter= 'W'"))
s = Replace(s, "E",  DLookup("Num", "tblLookupNumber", "Letter= 'E'"))
s = Replace(s, "R",  DLookup("Num", "tblLookupNumber", "Letter= 'R'"))  
' Etcetera

Open in new window

0
 

Author Closing Comment

by:cansevin
ID: 39919131
Thanks!
0
 

Author Comment

by:cansevin
ID: 39919164
mbizup... I am so sorry. I used your long "replace" and it worked great. I awarded the points to your wrong post. Hope that it is still ok. Thanks for the help!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39919221
No worries... Glad you got it working.    :)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

760 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

17 Experts available now in Live!

Get 1:1 Help Now