Access 2013 form field value gets cut off on changing the number before the point - vba

Recently I created a form which loads some records from an SQL (linked) database.
I want to display some field values (which are decimal numbers - 30,2 in the sql server).
The values are loaded in the form and displayed with a comma for the decimals and a point as a 1000 separator like this: 5.222,55. (Language settings on the computer).
Though the thing is, when I change the 5 before the point into any number then the value gets truncated and it sees the point as the decimal separator. So for example, if I only select the number 5 on the 5.222,55 number (so I leave the point) and then change it to a 2, the value is changed to 2,22.
Though when I select the whole number or the first number AND the point then it changes correctly. So how can I get this right? The easy way is to just select the whole number on changing but I just want it to work in every way. Perhaps I can achieve it with VBA? I tried setting the format option (back in access 2000 I believe I could set the text field to long integer or currency or something but I cant find this in the access 2013 field properties).
Additional information:
I am linking with a SQL server 2012,
The linked table in Access sees the fields record source (the SQL fields) as short text (while they are decimals in the SQL server)

Access cannot handle a 30,2 decimal, thus it is converted to text by teh ODBC driver.
So, either convert back and forth between text and numerics with Str and Val (the C* functions won't do), or change the data type of the field in SQL Server to, say, Money (= Currency in Access).

Related

MS Access rounding SQL decimal places

I currently run a process of using MS Access 2010 to import an Excel file into a SQL table. There are fields within this data that numeric fields calculated to 4 decimal places.
Access imports this to a field within the SQL table which is set up as [decimal](19, 4), where is displays fine. However, when I try to use Access to work with the data in this linked table, it converts it to 2 decimal places.
Access identifies this field as currency and assigns the decimal places to auto.
Is there any way I can use Access to query this data but to show 4 decimal places?
Thanks,
Using MS Access - Open the table in Design View. Click on the Currency field. Now you can see the Field Properties, where is the Decimal Places. Select the number of digits, 4 in your case, and save the table. I hope it works for you.

How to change number of decimal places stored in a table's field ms-access 2013 VBA?

I have a macro that formats my table, changes the field names and does a few other formatting operations before I push the data to a MySQL database. Now I want to be able to change the number of decimal places stored in the table to 2 numbers after the decimal. My field name is "Quantity". Is there a property I can use to set this in VBA? I have a web page that sits on the MySQL database, so I want to do all of the operations and other fixes in the Access db so that when I push the data, it is all ready to go.
Thanks in advance!
Run an UPDATE query like this:
UPDATE myTable
SET Quantity = Round([Quantity], 2)
There are no 2 dec digits data type in Acs. 4-fixed-digit only is Currency. If you need exactly 2 - you need to have two fields - Long for Integer part, and Byte - for decimal, I guess...
Please, keep in mind that proposed Round([Quantity], 2) is
Banking, not school (standard) rounding!
? Round(12.5)
12
? Round(13.5)
14
.

Access randomly drops decimals when inserting from txt file

I have a number of .csv files in the following format with example data listed:
ID,Lat,Long
1,-43.76120167,158.0299917
2,-43.76119833,158.03
3,-43.7612,158.0299983
4,-43.76120167,158.0299967
The values change from file to file, but they're always the same format and similar amounts. What you see above is exactly how it shows up in the .csv file (when opened with a texpad/notepad not in Excel - so we can eliminate any Excel problems now).
However, when I run the following INSERT statement as an Access SQL query:
INSERT INTO Table1 SELECT * FROM [Text;Database=C:\;Hdr=Yes].[ImportFile.csv];
This is what shows up in my Access database table:
ID,Lat,Long
1,-43,158
2,-43,158
3,-43,158
4,-43,158
Now, I know what you're thinking. Let me just say that my table design in Access is set up such that ID is a Number/Long Integer, and both of my Lat and Long fields are set up as Number/Double with 4 Decimal Places. I've double checked this a million times and it can be confirmed because not all input files share this problem.
This is what is troubling me... where are all the digits after my decimal point going? I need to have them.
What confuses me even more is that some files read just fine and the decimal points stay in there just fine... same table, same insert query. Every file is generated from the same source and formatted the same for what it's worth.
However, if I fire up Access itself and run the import from text file wizard, the values end up just fine. Access automatically makes the field a double with auto decimals (I have also tried using auto decimals in my desired table, to no avail).
Anyone have any idea what is going on?
Thanks!
This is well known problem.
The Jet database engine determines the data types from data source. One of solutions is to use/create Schema.ini file.
Also, keep in mind that, in order to determine data type for columns, only first few rows are scanned.
For more info, please see here

SQL Server 2008 - Column defined at 600 varchar only captures 255 characters

Why is the length for my longcomment field (defined as varchar(600)) only up to 255 coming from an Excel spreadsheet? The length of the value in the spreadsheet is over 300 characters and the field in the table is defined at varchar(600). However, when I select on that field in SQL, it is truncating at 255.
Thanks!
When an Excel files is parsed for import, only a certain number of rows are scanned to determine column size of the input. How you are importing the data makes a difference on what you need to change, basically you either need to override the detected column size or increase the number of rows scanned. Leave a comment with what import method you are using if you need additional help.
In Microsoft SQL Server Management Studio, you can change the size by going to the Tools/Option menu and opening the Query Results branch on the tree control. Then under the Results to Text leaf is the the “Maximum number of characters in a column” value.

Crystal Reports parameter selection limit?

I'm trying to make a Crystal Reports 11 report off an Oracle database that's grouped by user. I've got over one thousand users. I want to create a parameter field that prompts the person to select which users they would like to view the results for. However my parameter selection field is only showing 221 of the possible users. The users appear in alphabetical order because of the SQL command's Order By statement. I'm wondering if there is a limit to the number of dynamic default values that a parameter field can store. Any help with this would be great.
The default limit in Crystal 11 appears to be 1000 (held in the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 11.0\Crystal Reports\DatabaseOptions\LOV\MaxRowsetRecords), so your problem may lie in the construction of the parameter field itself. Make sure it is a dynamic parameter field that will query the database when used, as the odd number of values shown makes me think this was the list generated when the report was first run and saved, and therefore a static parameter list.
I tried to reproduce your situation using a database table with 5,000+ records.
I created a dynamic parameter (Crystal Reports XI R3, full version) on this field. It generated a unique list of values that appeared to be about 1,000 (I started to count it, but estimated its total size based on the scroll bar's position).
I added the registry entry HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite \Crystal Reports\DatabaseOptions\LOV\MaxRowsetRecords (String) and set its value to -1.
With the registry entry change, the LoV included all values.
When the LoVs had the record limitation, it appeared to sample values from each letter of the alphabet indiscriminately. Maybe this is what you are encountering.
221 sounds awfully low to be the default selection limit, at least to me. But there is a way to increase the number of records that these dynamic parameters pull in. It involves editing the registry.
See Here
The following is for Crystal Reports 2013.
Add a new registry entry under:
For 32 Bit computer
HKEY_HKEY_LOCAL_MACHINE\SOFTWARE\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\DatabaseOptions
For 64 Bit Computer (Wow6432Node sub note)
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\DatabaseOptions
Add a new key at that level called: \LOV
Add a string called MaxRowsetRecords
Set the value to whatever limit you want, I have selected 100000 in the development. (0 or -1, meaning all values, is no longer supported. )
After making changes to the registry, restart the affected service or application as required.
Just to clarify that the MaxRowsetRecords value does NOT refer to the number of distinct parameter values you can select from. It is the maximum number of records that Crystal will look at from which it extracts the dynamic parameter values. Most likely if you look at your query you will find that there are 221 unique values in the first 1000 records. Apply the registry change to a larger number and you should see more parameter values from which you can choose.