Erwin Craps
Erwin.Craps at ithelps.be
Wed Nov 26 10:54:33 CST 2003
Well I knew there where some formatting characters, no way I could find them in the Access Help. I've lost my patience with Access help since they putted it in HTML format. Thanks for the code again. Snifff, this makes me so happy :-) Lucky me, sniffff... No overtime today, straight to home.... I'll tell my wife and kid that I'm early today thanks to you.... -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock Sent: Wednesday, November 26, 2003 5:38 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Format of a field. Hi Erwin > This is probably the first time in probably 10 years I'm looking at > the field format in a table again. > I never used them because of never needed or wanted it. > I want to paper format an IBAN code which is 4 characters space 4 > characters space 4 characters etc. > something like this > 1234 ABCD 5678 EFGH 90 > The thing is that a IBAN code can be 34 character long wich means if > all 34 characters are used you have at the end 2 characters. > So I formated &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& && But instead > of aligning left it aligns right, so my code looks like > 12 34AB CD56 78EF GH90 > instead of > 1234 ABCD 5678 EFGH 90 > How can I resolve this that the code is left aligned and not right? > I could write some code to do this, but this is like a real good > situation where I could use the format property of a field/control. You are close. This is how to format a textbox: !&&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& && Also, we have this function for creating a formatted string: <code> Public Function FormatPaperIBAN(ByVal strIBAN As String) As String ' Formats Electronic IBAN (or Paper IBAN) strIBAN as Paper IBAN. ' ' Example: ' FR1420041010050500013M02606 ' formats as ' FR14 2004 1010 0505 0001 3M02 606 ' ' Limitation: Doesn't validate strIBAN except for string length. ' Use IsStrIBAN(strIBAN) for complete validation. ' ' Requires: ' MTrim() ' ' 2003-06-25. Cactus Data ApS. CPH. Dim strPaperIBAN As String Dim strFormat As String Dim strTrim As String Dim strGroup As String Dim lngGroups As Long Dim lngIBAN As Long Dim lngLoop As Long ' Trim mid spaces from string. strTrim = MTrim(strIBAN) lngIBAN = Len(strTrim) If lngIBAN < pclngLenISO3166Alpha + pclngLenISO7064Check + pclngLenBBANMin Then ' Not a possible IBAN string. Else ' Calculate number of format groups. lngGroups = (lngIBAN - 1) \ pclngLenIBANPaperGroup ' Build left filling format string forcing uppercase. strGroup = String(pclngLenIBANPaperGroup, "&") strFormat = "!>" & strGroup For lngLoop = 1 To lngGroups strFormat = strFormat & Space(pclngLenIBANPaperGroupSpacing) & strGroup Next ' Fill string from left to right. strPaperIBAN = Format(strTrim, strFormat) End If FormatPaperIBAN = strPaperIBAN End Function Public Function MTrim(ByVal strString As String) As String ' Trims strString for mid and outer spaces. ' ' 1999-06-23. Cactus Data ApS. CPH. Const cstrSpace As String * 1 = " " Dim lngTemp As Long Dim lngChop As Long Dim lngLoop As Long Dim strTemp As String Dim strTrim As String strTemp = Trim(strString) lngTemp = Len(strTemp) If lngTemp > 0 Then strTrim = strTemp lngChop = 1 Do lngChop = InStr(lngChop, strTrim, cstrSpace) If lngChop > 0 Then ' A space is found. Shift one character and ' overwrite this space in string strTrim. lngLoop = lngLoop + 1 Mid(strTrim, lngChop) = Mid(strTemp, lngChop + lngLoop) End If Loop Until lngChop = 0 ' String strTrim now contains no spaces. End If ' Return net length of trimmed string. MTrim = Left(strTrim, lngTemp - lngLoop) End Function </code> /gustav > Erwin Craps > Zaakvoerder > www.ithelps.be/jonathan > This E-mail is confidential, may be legally privileged, and is for the > intended recipient only. Access, disclosure, copying, distribution, or > reliance on any of it by anyone else is prohibited and may be a > criminal offence. Please delete if obtained in error and E-mail > confirmation to the sender. > IT Helps - I.T. Help Center *** Box Office Belgium & Luxembourg > www.ithelps.be <http://www.ithelps.be/> * www.boxoffice.be > <http://www.boxoffice.be/> * www.stadleuven.be > <http://www.stadleuven.be/> > IT Helps bvba* ** Mercatorpad 3 ** 3000 Leuven > IT Helps * Phone: +32 16 296 404 * Fax: +32 16 296 405 E-mail: > Info at ithelps.be > Box Office ** Fax: +32 16 296 406 ** Box Office E-mail: > Staff at boxoffice.be <mailto:figures at boxoffice.be> > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com