We are working on an application using MS Acces 2003 and SQL Server 2005.
We are saving a fields that contain a text data for example 002215.28 but we want to display it on the screen in a special format for example like this 00 22 15.28.
To do so on the Form Design toolbar and in the Format property box, we type a custom format
00 00 00.##\.####
but when we open the form screen the data appear like it was saved in the table
Please may you advise
It seems that the column may be a text column, if so, you need say, ## ## ##\.##
To format the control using number formats, you must first convert to number with, say, Val:
=Val([TextString])
Make sure that the control does not have the same name as the column, call it, say txtTextString.
There are various disadvantages to this, including:
The control is not editable
Val will return zero for alphas, giving 00 00 00..
Val will return an error for Null values
The last two are not difficult to work around.
If the first is a problem, you may have to consider some VBA to fill the field.
Related
My table field is date/time and formatted like this:
mm/dd/yyyy hh:nn:ss
I want the user to see this (with the space appearing between date and time
__/__/__ __:__:__
I want an input mask that demands:
Either 1 or 2 digits for the month
Either 1 or 2 digits for the dat
All 4 digits for the year
SHOWS the space but just jumps over it for the user
Either 1 or 2 digits for each of Hours, Minutes and Seconds
Further, when setting up a DB, is it just smarter to have two separate fields for Date and Time. A collegue encouraged me to break them out ... seems sensible?
00/00/0000##00:00:00
See the outcome in the image
Controlled user input is not an easy task in Access, as it is optimised for the opposite: To be tolerant and accept many input sequences for date and time.
For the cases where controlled input is mandatory, I've written two articles including full code (too much to post here) and demo, that may give you some ideas:
Entering ISO formatted date with input mask and full validation in Microsoft Access
Current code at VBA.DateEntry.
and
Entering 24-hour time with input mask and full validation in Microsoft Access.
Current code at VBA.TimeEntry.
I have VBA code that I run from MS Access. This code creates tables (of different sizes depending on the size of a query) in a Word document, and thereafter fills that Word document, with values from a query's columns using the Range.Text property. One of these columns is a currency value and another a percentage value. These values display correctly in Access itself.
Unfortunately values are outputted as eg. 987.6 and 1234.5, instead of 987.60 and 1234.50. As small as this is, it is a requirement and was hoping to find a solution and I am entirely unsure how to do this or if its even possible.
Discounts are displayed as 0.18 or 0.30 instead of 18 and 30
I can show my code for the export of the data if required however didn't see how it affected this part that I require.
That is the answer:
Format(123123, "Currency")
The currency would be from your local settings.
Edit: See the screenshot - open the immediate window, there you may write
?Format(123123, "Currency") and you will see the result. Screenshot attached.
I'm very new to Microsoft Access and I'm working with some old files created with MS Access 97.
What I'm wondering is:
Why would a Memo field display a string filled with strange characters instead of the actual text? (some guesses: 1. Some sort of compression is in effect. 2. The text is encrypted. 3. The text is encoded in a different encoding then the one being used to display the text.)
Example string (from an actual file):
"©{aÉi~¬|ù(~tKÃ!"
And if there is a definite reason, how would I convert it to the actual text?
P.S. It's only these memo fields that are giving me trouble, all other fields display readable information.
When trying to compare Memo fields (as in sorting, or WHERE, Join on a field, or agrigating), they may be truncated.
Please see here
I am importing excel data using html, spring and apache POI API. I need to do some validations before saving the data.
For a cell, I need to check whether its value is greater than 01 and less than 32.
I have seen like
cell.getStringCellValue().matches(regex);
Using this I have reached in a solution like this
if(cell.getStringCellValue().matches("\b([1-9]|[12][0-9]|3[01])\b"))
But I have read like, using regExp for comparing numbers is not such a good Idea, it is mainly for strings.
So my question is , is there a better way to solve my problem, finding whether the cell value falls within a range.
You need to add 0 before [1-9] inorder to match the number range from 01 to 09.
\b(0[1-9]|[12][0-9]|3[01])\b
I have a spreadsheet which is a report from an external supplier. The date columns are formatted completely different from how a little acccess database works, so i decided to record a macro in excel to alter the 3 columns to a dd/mm/yyyy format (im uk btw). This all works great and the column isshowing as above and is listed as a 'DATE' format also.
Now i use access to link to this excel sheet by means of a linked table, but i noticed that any queries that i wish to filter on those fields in the form of a where clause, it does not pull in the expected result IE it pulls all dates and not the ones between what i asked for in the queryalmost as if it is not recognizing them as dates see the where clause below
WHERE LatestGamma.ConfirmedPortingDate Between [Please Provide 1st Date (dd/mm/yyyy)] And [Please Provide 2nd Date (dd/mm/yyyy)];
I also tested it by using actual dates in the between cluase and it still appears to ignore it.
When i look at the properties of linked table for those columns, it shows that the fields are: dd/mm/yyyy;# but are showing as text??
When i look at the excel macro to see what code the macro used for changing the date format of the columns i see:
Columns("F:H").Select
Selection.NumberFormat = "dd/mm/yyyy;#"
I have another excel sheet that is used as a linked table and date columns are working fine and show as date/time and not Text. Its almost as if excel is putting some meta data into the columns that is making access interprate them as text (even though they are formatted as date)
Im stuck her some help/advise would be great
Its hard to tell without looking at the file, but it seems the main culprit is the excel macro which is not converting the string to date format correctly. You can try converting string into date format by using something like this in excel VBA
Sub convert()
Dim str1 As String
str1 = Range("f6").Value
startdate = CDate(str1)
End Sub
You probably will have to loop thru all the cells to convert the string (text) into date format.
Sorted it in the end. It was more or less what i was thinking IE the column although was showing as a Date type seemed to be storing it as some sort of text. Anyway the way round it was to use the text to columns button and force it to be a date in DMY format.
Once i had tried it i then recorded the actions as a macro and copied the resulting code to my main macro at the end, bingo ! Access now sees it as a date and not text.
Not sure if it is a bug or not but Excel can be a real pain sometimes especially with phone numbers, having to store them as a data type text to keep the leading zero and then immediately converting them to General to allow vlookups etc. I guess that is the same sort of thinkg going on above showing as a date yet actually having like a suedo text meta thing going on...