Right justify entry for varchar data type : (
am 02.11.2007 21:19:59 von eighthman11
Hello everyone, I'm using Access 2000 and SQL 8.0
This maybe easy but I can't figure it out. I have a linked access
table to a SQL server table. I use this table on a Grid on an Access
form. There is a field on the grid for the Equipment Number the field
is called Equipment (I know original).
The data type for this field is varchar with a length of 10 and the
data is rigth justified in the table
on the SQL Server.
The grid is only for doing edits (no new records can be added). When
the user changes the Equipment number on the grid I need that data to
be right justify with spaces on the left. Now you can manually enter
spaces in the textbox first and then enter the number but that's not
realistic to ask the user to do that. The way it is now if the user
just enters the number when the change hits the Equipment table the
number is Left justified which is an invalid Equipment Number.
Anyway to have spaces padded to the left with code. I tried this on
the before update event but Access did not like it Me.Equipment =
Right(" " & me.Equipment, 10). I got an error message saying
that the code was preventing me from updating the record.
Any help appreciated-----thanks
Re: Right justify entry for varchar data type : (
am 02.11.2007 21:49:29 von Rich P
Be aware that adding spaces to your data as you describe will change the
value of that data (or force you to use ltrim(rtrim()) all over the
place. I would advise against adding spaces to the actual data. If
someone needs to view this data as right justified during data entry
then you need to create a data entry form where the text in the
textboxes is right justified. A datasheet view should not be used for
data entry. That is like entering data directly into a table which
defeats the value of having a frontend application where you can trap
errors control data entry...
Rich
*** Sent via Developersdex http://www.developersdex.com ***
Re: Right justify entry for varchar data type : (
am 03.11.2007 05:46:18 von Tom van Stiphout
On 02 Nov 2007 20:49:29 GMT, Rich P wrote:
I agree with everything you say, but couldn't:
ltrim(rtrim())
be replaced with:
trim$()
-Tom.
>Be aware that adding spaces to your data as you describe will change the
>value of that data (or force you to use ltrim(rtrim()) all over the
>place. I would advise against adding spaces to the actual data. If
>someone needs to view this data as right justified during data entry
>then you need to create a data entry form where the text in the
>textboxes is right justified. A datasheet view should not be used for
>data entry. That is like entering data directly into a table which
>defeats the value of having a frontend application where you can trap
>errors control data entry...
>
>Rich
>
>*** Sent via Developersdex http://www.developersdex.com ***