Solved

Fromating Fields

Posted on 2014-09-15
10
115 Views
Last Modified: 2014-09-15
I including a Database with a query.  I need the query to do the following:
1.       Crte_DTTM-Format to be only Date
2.      Ver_NUM-If equal 1 the append AO
 If equal 2 the append GN
If equal 3 the append GO
If equal 4 the append CO
If equal 5 the append GNII
If equal 6 the append GNA
Thank you in Advance.
FormatDB.mdb
0
Comment
Question by:ca1358
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 84
ID: 40323327
This looks more like a statement or work than a request for help.

Can you post your query that you have now, and perhaps explain what you've tried? The experts are here to help YOU do your job - not do it for you.
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40323329
I have no real idea as to what you are asking.

However, the answer to part 2 seems to be:

CHOOSE(Ver_NUM,"AO","GN","GO","CO","GNII","GNA")
0
 
LVL 84
ID: 40323338
To help with your query:

You can format a DateTime field to show the Date portion only by using the Format function:

SELECT Field1, Format(YourDateField, "mm-dd-yyyy") AS FormattedDate FROM YourTable

You can also use nested IIF statements, or the Switch method, to show different values depending on the value in a field. For example:

SELECT Field1, IIF(Field2='AO', 'A', IIF(Field2='AB', 'B'), 'C') AS SomeField FROM SomeTable

To use Switch:

SELECT Field1, Switch(Field2="AO", "A", Field2="AB", "B", Field2="AC", "C") AS SomeField FROM SomeTable
0
 

Author Comment

by:ca1358
ID: 40323347
I included the sample database with the queries that I am having problems with.  Name of Database is FormatDB.mdb

I have formated 200 fields, these two fields I am troubling with.  So just want some help Formating these two fields.
0
 
LVL 9

Accepted Solution

by:
macarrillo1 earned 500 total points
ID: 40323364
Here is what you need.

The Ver_Num would be:

Ver_Num: IIf([Table1]![Ver_Num]="1","AO",IIf([Table1]![Ver_Num]="2","GN",IIf([Table1]![Ver_Num]="3","GO",IIf([Table1]![Ver_Num]="4","CO",IIf([Table1]![Ver_Num]="5","GNII",IIf([Table1]![Ver_Num]="6","GNA","ERROR"))))))

see attachment.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 9

Expert Comment

by:macarrillo1
ID: 40323374
For the date field you just needed to change the property to display the format as short date.
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40323377
My answer is shorter - use the Choose function.
0
 

Author Closing Comment

by:ca1358
ID: 40323381
Thank you for your Help .
0
 
LVL 9

Expert Comment

by:macarrillo1
ID: 40323382
As I re-read your request were you asking to update the field
Ver_Num to the values listed or did you
mean [Ver_Num] + Value as in
1AO
2CO
3GN
etc.
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 40323393
I don't recommend formatting Date fields in queries unless you are exporting the query as a csv or to excel.  It is best to format dates where they are displayed on reports or forms.

In a query if you need only the date part of a datetime field and you want the field to retain its property as a date so you can still sort it like a date or compare it to other dates, then use the DateValue() function.  The Format() function suggested by Scott actually turns a date into a string so it no longer sorts like a date or compares like a date although it is the function of choice when formatting is required due to its options.

As an example 1/1/2014 will sort BEFORE 1/2/2013 if the field is a string data type but AFTER if the field is a date data type.  Strings are processed character by character, left to right where as numeric fields (such as a date) are  aligned at the decimal point and sorted by order of magnitude so negative numbers sort descending first followed by positive numbers ascending.
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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
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, when working with VBA, learn some techniques for writing readable and easily maintained code.

705 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

18 Experts available now in Live!

Get 1:1 Help Now