Number Format In Sql Queries

Apr 3, 2007

I was about to post a question yesterday, but I found a solution myself and would like to share it. When a new column is computed in the query, there is no way to prescribe the data format of the computed column (=field =variable). It is done automatically by access and it can go wrong. I tried to use Format() function but it changes the look but does not change the type of the column. So what you have to do is to wrap your expression in a data convertion function. I used CDBL() as a wrapper for my expression.

I consider it as a bug of Access because in my situation I had a swich() function that took only numeric fields and produced only number but the data type of the column was set to TEXT. I noticed it in the pivot table later on , when I could only use Count() as aggregate function.

Good luck! and take care of data conversion by yourself, do not let it go automatically!

P.S. If anyone knows a better way to prevent such conversion errors, be my guest!!!

By
Maxim Ivashkov
http://www.4suc6.com

View Replies


ADVERTISEMENT

Queries :: Search Like And Phone Number Format

Apr 12, 2013

I have the following VBA code to search for a string

Code:
'Search by Phone
Private Sub CmdSearchPhones_Click()
Me.Refresh
strSQL = "SELECT Tbl_Contacts.ContactID, Tbl_Contacts.FName, Tbl_Contacts.LName, Tbl_Contacts.Address, Tbl_Contacts.City, Tbl_Contacts.State, Tbl_Contacts.Zip, Tbl_Contacts.HomePhone, Tbl_Contacts.WorkPhone,

[Code] .....

My issue is that this works 50/50, because phone numbers on the database are NOW being stored in this format (000) 000-0000 and previous DB phone numbers got stored as 0000000000. The above code finds previous DB phone numbers (even if we dont enter all 10 digits) without a problem but has issues with new phone numbers stored in the new format UNLESS I specify the search with (000) 000-0000 (but we want to be able to search without adding that and without typing all 10 digits - in case we forget part of the number we are looking for)

How can I tell my query to find both formats, with the (000) 000-0000 AND 0000000000 ....

View 4 Replies View Related

Queries :: Convert Phone Number In Text Format And Remove Dashes Or Parenthesis

Aug 7, 2014

Is there a way to convert a phone number in text format into a number and remove any dashs or parenthesis. What function can I use ?

old format (951) 244-3011
new format 9512443011

View 2 Replies View Related

Number Format To General Format

May 4, 2012

I am exporting data from access 2007 to Excel 2007 using VBA code. I have a whole number, which I want displayed as whole number. But after the export, the number is using the 1000's seperator in Excel. So for example if my original number in access table is 12000, it is showing up as 12,000 in the excel file.It has something to do with the NumberFormat property. I have tried doing this but doesn't work.

objSheet.Range("A1:A7").NumberFormat = "General"

View 2 Replies View Related

Number Format

Feb 9, 2007

I have Set a Field as a Long Integer (and have tried Standard) Number with two decimal places. I enter data and it always displays as .00 and not the correct figures. Any clues anybody?

View 14 Replies View Related

Format Number

Apr 27, 2007

I have a query that looks like this, datediff("d",[end_date],[start_date])/30
it's working perfect, but it's give me a decimal number, how can I formate it to get rid of the decimals, if I put "m" instead of the "d" than this number won't be accurate, can someone help? thanks.

View 2 Replies View Related

Number Format

Nov 21, 2004

I am trying to enter a field with total hours for the day. I have set as "General number, 2 Decimal places. When
I input the number [18.25] which means 18 and 1/4 hours..... The field will only display 18.00, I can not get it to
show the .25.... I think the field is rounding off the number and if it is how do I get it to stop... I need this field to
give me a sum in a report.... Need some help....

View 2 Replies View Related

Number Format For IP Addresses

Feb 20, 2007

I need some input on what to use for a field that contains a range of IP addresses, and have it sort numerically by octet. I currently have that field assigned as text, but were not happy with the sort order. I've played a little with the number format type, but still did not get the correct sort order. Any suggestions would be appreciated. Thanks

View 2 Replies View Related

Combobox - Number Format

Jun 24, 2006

I have been confronted with a strange fenomenon in comboboxes.

I'm working with access2000.
I put a simple combobox in a form.
The row source of the combobox is a table and the first field of this table is a number.
The bound column is 1.
When I select a record in the combobox, that number appears, it all seems to work.

However, when I reference the content of the combobox via a query, I receive strange characters.
When I ask for the ASCII value of that character, it is mostly 49 (1) or 50(2).
When I set the column width to zero, the references just work fine.
When I change the format to text, everything works fine.

Can someone explain why this is happening?

I include a simple database to show what is happening.
Look at the queries.

otto

View 9 Replies View Related

Format A Number As A Text In A Query

Apr 5, 2007

Hello,
I have a text file I'm querying that stores a field as a text.
ComponentID:0000000242

I'm inserting this data into a table that stores this value as a number. Thus truncating the leading zeros.
ComponentID:242

I would like to create a query on the table using an InnerJoin on the text file column:ComponentID:0000000242 and the table column:ComponentID:242 as the unique identifier. Doing this join gives a case error because of the different data types.

Can format ComponentID using a query so it reads from my table as 0000000242 and do an InnerJoin to the text file. In vb
String= Format(242, "0000000000")
But I'm finding it difficult to get the query to format this correctly.

Unfortunately, i'm unable to change the column data type in the table structure and am looking for a work around. Is this even possible? Any ideas?

Thanks.

View 1 Replies View Related

Format Number Within Text String

Oct 19, 2006

hi
I'm no expert and can't seem to find what i'm looking for.

i have data i enter into a text box. the data might be in the format

"name"
OR
"name, date, age"
OR
"name, date"

if on the second or third example above i entered the data like shown below how would i VB code the afterupdate to do this:

turn
David Roberts, 12122006
to
David Roberts, 12/12/2006

OR turn
David Roberts, 12122006, 56
to
David Roberts, 12/12/2006, aged 56

any ideas??
I'm working along the lines of instr, mid, etc. but i'm not sure of the correct procedure
thanks in advance

View 5 Replies View Related

Forms :: Number Format With Space

Jul 15, 2013

In my table i have a field ID here are values like as 123456 234345 233434

I wanna make report with this table, here ID field will be shown up with space every number

Example : file value : 12345

I want in report : 1 2 3 4 5 6

View 4 Replies View Related

How To Format A Number Data Type

Dec 15, 2012

I am trying to format my Number data type to look like this: 0001 / 2013 where "0000" is the prefix, 1 is the number and " / 2013" is the suffix.

Tablename: tblclients
Field Name: DelNoteNo
Data type: Number

Form
Control Name: DelNoteNo
Control Source: DelNoteNo

I am searching on this forum but I can't get it working.On the Before Up date procedure i have:

DelNoteNo = Nz(DMax(DelNoteNo, "tblClients"), 0) +1

but its is giving "invalid use of Null "

View 4 Replies View Related

Please Help With Weird Access Number Format Problems

Sep 16, 2005

Hi there,

I have imported in an excel table into access. It has a lot of numbers that have many digits after the decimal place. I want to cut this down since they are prices to just 2 decimal places.

Problem is that access imports the fields as Text fields. when i go to change the columns that i want as numbers it looses the information after the decimal place for example 1.1156834 when i click Number (long integer) and standard format it is converted to 1.00 loosing everything.
This is getting really really fustrating now.

When i import there is a drop down list but it is disabled where i can change the column property (number, text etc) so cant do anything about it.

any help would be great...
Dan

View 1 Replies View Related

Please Help With Weird Access Number Format Problems

Sep 16, 2005

Hi there,

I have imported in an excel table into access. It has a lot of numbers that have many digits after the decimal place. I want to cut this down since they are prices to just 2 decimal places.

Problem is that access imports the fields as Text fields. when i go to change the columns that i want as numbers it looses the information after the decimal place for example 1.1156834 when i click Number (long integer) and standard format it is converted to 1.00 loosing everything.
This is getting really really fustrating now.

When i import there is a drop down list but it is disabled where i can change the column property (number, text etc) so cant do anything about it.

any help would be great...
Thanks
Dan

View 2 Replies View Related

Date Format And Auto Number Combo

Aug 23, 2007

I have a query that I want the Now() function in the year only format and in an expression combine with the auto number one extra field to get the following:date YYYY-------Autonumber---------color----------exp1: ---2007--------------23--------------green-------2007-23-greenThanks for the help

View 1 Replies View Related

Correct Week Number Format In A Query

Jan 6, 2005

Wondering if anyone can advise...

The 1st/2nd Jan of this year were treated by most people as still being week 53 of 2004, and week commencing 3rd January being week 1 of 2005. In VB I have a formula to do this:

WeekNo = Format(Now(), "ww", vbMonday, vbFirstFourDays)

However my problem now is that I need to replicate this format in a Query within Access. The formula

WeekNo: Format(Date(),"ww")

treats 1st/2nd Jan as week 1, the 3rd as week 2 etc. Any idea how I can get it to treat 3rd Jan as week 1 instead?

There's a challenge for someone!! Help appreciated.

View 1 Replies View Related

Forms :: Using Format Control In Auto Number

Mar 24, 2014

I need the auto number to be in specified format as ASI-23-0001. So I added the format "ASI-23-"0000 in the formats and I got it succesfully.The fueld name is "Part Number"

I have added the Part Number field to a form as combo and I was able to list the values in the drop down combo.

I wanted to use Dlookup command in the program to auto fill the next field in the form say "Description".

I am using the following code
Me.Text30 = DLookup("[Description]", "item_master", "[Part Number] = Form![Combo36]")

But now the data in the combo is treated as text because of the prefix "ASI-23" and I get data type mismatch error.

View 5 Replies View Related

Tables :: Can Format Auto-number For A Primary Key

Jun 23, 2013

Is there a way I can format AutoNumber for a primary key, for example, have the first ID start as C001 then for the next entry Access will automatically go to C002, and so on and so forth?

View 14 Replies View Related

Tables :: Format Auto-number Field

Oct 25, 2012

I would like to format the AutoNumber field so that it shows the current year - #...i.e. 2012-01.

View 4 Replies View Related

Reports :: How To Keep Data Type In Number Format

Mar 7, 2013

In my report, I have combo boxes that display numbers (for example min_revenue and max_revenue).

In case of a "0" or "999.999", I would like to display "n/a" within the combo-boxes.

I would like to avoid doing this within the table, because I would like to keep the data type in number format.

Remark: I confused "combo-box" with "text box". I'm using text boxes, which are supplied with values from a table

View 6 Replies View Related

Reports :: Number Format Displaying Incorrectly

Sep 19, 2013

I have created a report from a query. The report contains some numeric fields.

I have set the format of the numeric fields to #,###;#,###;0;0;

Despite this setting, my report is showing numbers as #.###

View 1 Replies View Related

General :: Undefined Function Format Number

May 25, 2013

I looked for missing references after I had received this message. List of available references had 4 selected items:

1) Visual Basic for Applications;
2) Microsoft Access 15.0 Object Library;
3) Microsoft Office 15.0 access database engine library
4) OLE Automation;

I tried to check off the 3rd and the 4th one, but it came to nought (error didn't dissapear). What else can I do ?

View 6 Replies View Related

Phone Number Format Problem With Mail Merge

Jul 26, 2006

Twilight Zone Phormat Problem

I have a mail merge from Access into Word that works great except for a baffling problem with phone number formatting. Instead of (987) 654-3210, on certain records the merge produces 9876543210. I cannot identify a pattern to explain it, but it is not random. Certain records consistently leave the format behind on the phone number, some on the fax number, and some on both. This problem is affecting about 1/3 of the contact records. I have the Input Mask on Phone and Fax in the table set to !(999") "000-0000;0;_. Is anyone familiar with this problem?

View 1 Replies View Related

Convert Day Of Year Date/time Format To Number

Mar 11, 2008

Hi all,

I have an inherited database with years worth of julian dates stored as numbers (e.g. days 1-366 for a leap year). I also have some fields stored as short dates. I would like to run a series of parameterized queries on this data, some using the short data and some using the "julian dates" that are actually just numbers. I have the user enter the start and end date in short date format and would like that to be converted and held in an unbound field as a number value. So far I can get the date to appear as a "julian date" (e.g. 1/1/08 appears as 1, obviously the underlying data is still 1/1/08) How do I take that 1 and convert it to number value "1"? Thanks in advance.

Cheers,
Peter

View 7 Replies View Related

Format Date Yymm Based On Number Of Months.

May 25, 2006

I am importing data to a program that requires the life of an item. This is in months such as 241 months. The valid format for this program is YYMM. 241 = 2001 or 20 years 01 month.

Another example: 16 months should read 0104 or one year 4 months.

Any idea how to convert this to yymm format based on the number of months?

thanks in advance.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved